Trideep Trideep - 4 months ago 59
Android Question

How do I create overlay button in my Android layout

I want to create a button which will overlay between 2 layouts.
I am using Linear Layout and added appropriate weight to it.
Have attached a screen shot for reference.

enter image description here

Here is my XML
tag.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:weightSum="100" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="30"
android:background="@color/greyColor"
android:gravity="center" >

<ImageView
android:id="@+id/ximgvwCamera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/camera_big" />
</RelativeLayout>

<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="70"
android:background="@android:color/white" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@android:color/white"
android:gravity="center_horizontal"
android:orientation="vertical" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:padding="5dp"
android:text="@string/strQ1"
android:textAppearance="@android:style/TextAppearance.Medium"
android:textColor="@android:color/darker_gray" />
</LinearLayout>
</ScrollView>




Please help me in this.
Thanks in advance!

Answer

Try this it will working...

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="150dp" >

        <ImageView
            android:id="@+id/imageCover"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY"
            android:src="@drawable/image_top" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:background="@drawable/image_bottom"
        android:layout_height="match_parent" >
    </LinearLayout>
</LinearLayout>

<ImageView
    android:id="@+id/imageProfile"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_gravity="end"
    android:layout_marginTop="100dp"
    android:src="@drawable/ic_launcher" />

</FrameLayout>

View like this

enter image description here