Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android, ImageView over ImageView

I have a quite simple question to ask: I need to put a small logo over an ImageView, large all the screen, in the bottom right area of the screen, but I don't know how to set the coordinates or how to say the ImageViews to be in a relative position.

Something like this:

enter image description here

like image 943
Stefano Avatar asked Jul 13 '12 09:07

Stefano


2 Answers

Try this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/ic_launcher" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_launcher" />

</RelativeLayout>

Output

enter image description here

like image 157
MAC Avatar answered Nov 05 '22 13:11

MAC


Use FrameLayout.

As per Google Blogspot Sample

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView  
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 

        android:scaleType="center"
        android:src="@drawable/golden_gate" />

    <TextView
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="20dip"
        android:layout_gravity="center_horizontal|bottom"

        android:padding="12dip"

        android:background="#AA000000"
        android:textColor="#ffffffff"

        android:text="Golden Gate" />

</FrameLayout>

Which will give you following output

enter image description here

Just tweak it to suit your needs.

like image 26
Vipul Avatar answered Oct 26 '22 19:10

Vipul