Solution 1 :
Use this code android:layout_gravity=”bottom”
hope it will work for you
<Button
android_id="@+id/about_button_terms_and_conditions"
android_textAllCaps="false"
android_layout_width="250sp"
android_layout_height="wrap_content"
style="@style/Widget.AppCompat.Button"
android_layout_gravity="bottom"
android_text="@string/about_terms_and_conditions"
android_layout_marginBottom="30dp"/>
Solution 2 :
use this Tag
android:layout_gravity="bottom"
Problem :
I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns_android="http://schemas.android.com/apk/res/android"
xmlns_app="http://schemas.android.com/apk/res-auto"
android_layout_width="match_parent"
android_layout_height="match_parent">
<LinearLayout
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_orientation="vertical"
app_layout_behavior="@string/appbar_scrolling_view_behavior"
android_layout_marginTop="30dp">
<TextView
android_id="@+id/about_header"
android_layout_gravity="center_horizontal"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_text="@string/app_name"
android_textColor="@color/primaryColor"
android_textSize="60sp" />
<TextView
android_id="@+id/about_version"
android_layout_gravity="center_horizontal"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_textColor="@color/primaryColor"
android_textSize="25sp" />
<ImageView
android_id="@+id/about_image"
android_layout_marginTop="10dp"
android_layout_width="match_parent"
android_layout_height="100dp"
app_srcCompat="@drawable/environment" />
<Button
android_id="@+id/about_button_privacy_policy"
android_textAllCaps="false"
android_layout_width="250sp"
android_layout_height="wrap_content"
style="@style/Widget.AppCompat.Button"
android_layout_gravity="center"
android_text="@string/about_privacy_policy" />
<Button
android_id="@+id/about_button_terms_and_conditions"
android_textAllCaps="false"
android_layout_width="250sp"
android_layout_height="wrap_content"
style="@style/Widget.AppCompat.Button"
android_layout_gravity="center"
android_text="@string/about_terms_and_conditions"
android_layout_marginBottom="30dp"/>
</LinearLayout>
</ScrollView>
I want to have a big space between the image and the two buttons on the bottom. Something like:
[title]
[title]
[image]
[Button]
[Button]
I used marginTop
but in some devices you can’t see the bottom. I would like to use something more robust. I’m using API 16. Is there a way to fix the two buttons to be for example “15dp” from the bottom?
Comments
Comment posted by Beko
Try
Comment posted by Mervin Hemaraju
marginTop is the best way to go in my opinion and it should work in all devices. If it doesn’t work in “some devices” then it should be another issue which you need to test by checking the layout inspector on this specific device.
Comment posted by ConstraintLayout
Why don’t you use a