Overlay image over another android

user2291423 picture user2291423 · May 28, 2013 · Viewed 22.9k times · Source

I have photo album which shows the image as rounded with white border. Image will be adding dynamically. I tried frame layout but it it not working for me. My try : Adding dynamic image over already existing round shape image..

<FrameLayout
   android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<ImageView 
    android:id="@+id/image"
    android:layout_width="60dip"
    android:layout_height="60dip"
    android:adjustViewBounds="true"
    android:scaleType="centerCrop" />

<ImageView 
    android:id="@+id/imagef"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:background="@drawable/ph_bg" />
</FrameLayout>

Above xml not giving exact result .. any idea ?

Answer

Pankaj Kumar picture Pankaj Kumar · May 28, 2013

Use below xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="60dip"
        android:layout_height="60dip"
        android:adjustViewBounds="true"
        android:layout_centerInParent="true"
        android:scaleType="centerCrop" />

    <ImageView
        android:id="@+id/imagef"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        android:background="@drawable/ph_bg" />

</RelativeLayout>

This will do your task.

Happy coding :)