I have a imageview & relative layout, where the layout containing two buttons should align to bottom and circular image should stretch to take remaining space. I tried from other answers but could not do it. I have code and image below.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cardview_light_background"
android:clickable="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/toolbar_child_with_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar_child"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_child">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/iv_SavedInvoice"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/service_app_logo"
android:scaleType="fitStart"
android:adjustViewBounds="true"
android:layout_centerHorizontal="true"
/>
<LinearLayout
android:id="@+id/ll_inner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/iv_SavedInvoice"
android:layout_alignParentBottom="true"
>
<Button
style="@style/PrimaryButton"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/form_proof_replace_invoice"
android:id="@+id/button_ReplaceInvoice" />
<Button
style="@style/NoBorderButton"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/form_proof_next"
android:id="@+id/button_SavedProofNext" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
I don't know why you used ScrollView and other Nested Layout. The UI that you want can be simply achieved by using layout weight attribute. You check this code and make changes according to your need.`
<?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:background="@color/cardview_light_background"
android:clickable="true"
android:orientation="vertical">
<include
android:id="@+id/toolbar_child"
layout="@layout/toolbar_child_with_progress"
android:layout_width="match_parent"
android:layout_height="50dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/iv_SavedInvoice"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:scaleType="fitStart"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
<LinearLayout
android:id="@+id/ll_inner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/iv_SavedInvoice"
android:orientation="vertical">
<Button
android:id="@+id/button_ReplaceInvoice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="form_proof_replace_invoice" />
<Button
android:id="@+id/button_SavedProofNext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="form_proof_next" />
</LinearLayout>
</LinearLayout>