I have two imageviews that I would like to set second imageview over first image like below image :
first image:
second image (moment) :
how can I do ?
I wrote below codes, but it does not works fine :
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:scaleType="fitXY"
android:src="@drawable/ic_moment"
/>
<ImageView
android:id="@+id/img_view_item_main_list"
android:layout_width="fill_parent"
android:layout_height="220dp"
android:scaleType="fitXY"
android:src="@drawable/testtesttest" />
Use Framelayout
or use merge tag
eg:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/t" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</FrameLayout>
second image comes on the top
try to do something like as follows
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white" >
<ImageView
android:id="@+id/inside_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:src="@drawable/frame" />
<ImageView
android:id="@+id/outside_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/inside_imageview"
android:layout_alignBottom="@id/inside_imageview"
android:layout_alignLeft="@id/inside_imageview"
android:layout_alignRight="@id/inside_imageview"
android:scaleType="fitXY" />
</RelativeLayout>
Also you can visit how to place an image over another one on android app?
Try this way,hope this will help you to solve your problem.
Take FrameLayout as parent and set top image layout gravity top and let.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/ic_moment" />
<ImageView
android:id="@+id/img_view_item_main_list"
android:layout_width="wrap_content"
android:layout_height="220dp"
android:scaleType="fitXY"
android:layout_gravity="top|left"
android:src="@drawable/testtesttest" />
</FrameLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With