Android的:在上一个ImageView的图像显示的图像 [英] Android: Display image over an Image in ImageView
问题描述
我用的LinearLayout
两个的ImageView
机水平放置。我有图像放在的ImageView
。现在我需要在图像上的ImageView
添加一个小的图像。我已经看到了很多帖子,但他们都以 RelativeLayout的
或的FrameLayout
交易。下面是我使用的XML code段。
I'm using LinearLayout
to place two ImageView
horizontally. I have image placed on ImageView
. Now I need to add an small image over the image on ImageView
. I have seen a lot of post but all of them deals with Relativelayout
or Framelayout
. Here is the XML code segment that I have used.
<LinearLayout
android:id="@+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imgmode31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:adjustViewBounds="true"
android:maxHeight="180dp"
android:maxWidth="140dp"
android:scaleType="fitXY"
android:src="@drawable/i5" >
</ImageView>
<ImageView
android:id="@+id/imgmode32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:longClickable="false"
android:maxHeight="180dp"
android:maxWidth="280dp"
android:scaleType="fitXY"
android:src="@drawable/i1" >
</ImageView>
</LinearLayout>
任何帮助将是非常美联社preciated。
Any help will be highly appreciated.
推荐答案
这正是一个线性布局应该是prevent。但是,您可能能够覆盖使用负填充下一个元素的定位。这样做的问题是不同的屏幕密度会发生什么。
This is exactly what a linear layout is supposed to prevent. You may however be able to override the positioning of the next element using negative padding. The problem with that is what happens on different screen densities.
我想这是从表面上看是为。它提供了一个透明的绘图表面整个屏幕让您在其他意见绘图。
I think this is what a surface view is meant for. It provides a transparent drawing surface over the entire screen allowing you to draw in top of other views.
最后一个想法是把你的第一个形象在你的线性布局内的框架布局。然后,你可以使用填充来定位它的叠加图像添加到框架布局。
One last idea would be to place your first image in a frame layout inside your linear layout. Then you could add your superimposed image to the frame layout using padding to position it.
这篇关于Android的:在上一个ImageView的图像显示的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!