Search code examples
androidandroid-linearlayoutandroid-relativelayout

Place a button in Relative layout below the custom zoomview


I want to place a Relative layout below the custom Zoomview. I don't want the content of Relative Layout to get Zoom. I want a button to be placed at center of that relative layout.

Here is my XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/images">

<com.example.acer.myapplication.ZoomView
    android:id="@+id/iop"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:text="@string/twentyfive" />
</LinearLayout>

Solution

  • <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/images">
    
    <com.example.acer.myapplication.ZoomView
        android:id="@+id/iop"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center"
        android:text="@string/twentyfive" />
    
    <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <Button
                android:layout_centerInParent="true"
                android:text="Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
    
    </RelativeLayout>
    
    
    </LinearLayout>
    

    Never tested code, but hopefully it will work.