Android:将图像放在另一个图像上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22033358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android:Put an image over another image
提问by Abid Khan
I have three ImageViews
and i want 1 ImageView
to be in the background and the other 2 images should be laying on that one. I cannot use any other view because the image is downloaded in the image form that cannot be set as Linear
or Relative
layout background.
我有三个ImageViews
,我希望 1 个ImageView
在背景中,其他 2 个图像应该放在那个图像上。我无法使用任何其他视图,因为图像是以无法设置为Linear
或Relative
布局背景的图像形式下载的。
FIRST IMAGE
第一张图片
THIS IS THE SECOND IMAGE WHAT I WANT ACTUALLY
这是我真正想要的第二张图片
回答by Hamid Shatu
You can try as below xml layout...
您可以尝试如下 xml 布局...
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/ic_launcher"
android:scaleType="fitXY" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="100dip"
android:background="@drawable/ic_launcher" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="100dip"
android:background="@drawable/ic_launcher" />
</FrameLayout>
回答by Eldhose M Babu
You can use like this :
你可以这样使用:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
回答by Buru
To overlapviews or block a display area for a single itemFrame layout(here) can be used.
要重叠视图或阻止单个项目的显示区域,可以使用 框架布局(此处)。
you can use
您可以使用
<FrameLayout
android:layout_width="..."
android:layout_height="..."
android:background="Image1"
<ImageView
android:layout_width="..."
android:layout_height="..."
android:background="image2">
<ImageView
android:layout_width="..."
android:layout_height="..."
android:background="image3">
</FrameLayout>
回答by jyomin
First use a relativie layout in that add image view with width and height set as match parent.Then take second image view alignParentTop property true for that and similarly for third imageview align its property parentbottom true with width and height set as wrap content
首先在添加图像视图中使用相对布局,宽度和高度设置为匹配父级。然后将第二个图像视图的 alignParentTop 属性设为 true,同样对于第三个图像视图,将其属性 parentbottom 对齐,宽度和高度设置为换行内容
回答by Saad Anwar
You can use layer-list make layers.xml in your drawable Something like this
你可以在你的 drawable 中使用 layer-list make layers.xml 这样的东西
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<item>
<bitmap android:src="@drawable/img1"
android:gravity="center"
/>
</item>
<item>
<bitmap android:src="@drawable/img2"
android:gravity="center"
/>
</item>
</layer-list>