Android: Display Image Over An Image In ImageView
Solution 1:
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.
Solution 2:
you can do it easily with relative layout
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/i5"
android:id="@+id/imgmode31"
android:maxHeight="180dp"
android:maxWidth="140dp">
</ImageView>
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scaleType="fitXY"
android:longClickable="false"
android:adjustViewBounds="true"
android:src="@drawable/i1"
android:id="@+id/imgmode32"
android:maxHeight="180dp"
android:maxWidth="280dp">
</ImageView>
</RelativeLayout>
if you want ImagView
to overlap each other then make their Height
and Width
same and you can also bring any of the ImageView
at front in runtime
Solution 3:
A LinearLayout
places elements linearly, one next to the other. If you want to place an element on top of another, then you need to resort to a FrameLayout
or RelativeLayout
.
If you change your LinearLayout
to a FrameLayout
you should see the two ImageView
s overlapping.
Post a Comment for "Android: Display Image Over An Image In ImageView"