Professional Documents
Culture Documents
- Stack Overflow
<TextView android:text="@string/welcome"
android:id="@+id/TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
<LinearLayout android:id="@+id/LinearLayout"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom">
<EditText android:id="@+id/EditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
<Button android:text="@string/label_submit_button"
android:id="@+id/Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
</LinearLayout>
EDIT:
<TextView
android:text="@string/welcome"
android:id="@+id/TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
</TextView>
<RelativeLayout
android:id="@+id/InnerRelativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:text="@string/label_submit_button"
android:id="@+id/Button"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<EditText
android:id="@+id/EditText"
android:layout_width="fill_parent"
android:layout_toLeftOf="@id/Button"
android:layout_height="wrap_content">
</EditText>
</RelativeLayout>
</RelativeLayout>
android-layout
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 2/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
asked Mar 5 '10 at 13:04
gav
15.7k 21 54 87
18 Answers
<android.support.constraint.Constraint
xmlns:android="http://schemas.andro
xmlns:app="http://schemas.android.c
xmlns:tools="http://schemas.android
android:layout_height="match_parent
android:layout_width="match_parent"
<android.support.design.widget.Floatin
android:layout_height="wrap_conten
android:layout_width="wrap_content
app:layout_constraintBottom_toBott
app:layout_constraintEnd_toEndOf="
</android.support.constraint.Constrain
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 3/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
<ScrollView
xmlns:android="http://schemas.andr
android:layout_height="match_paren
android:layout_width="match_parent
android:fillViewport="true">
<LinearLayout
android:id="@+id/LinearLayout0
android:layout_width="match_pa
android:layout_height="match_p
xmlns:android="http://schemas.
android:orientation="vertical"
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent
<TextView android:text="welcome"
android:id="@+id/TextView"
android:layout_width="fill_par
android:layout_height="wrap_co
</TextView>
<RelativeLayout
android:layout_width="match_pa
android:layout_height="match_p
<Button android:text="submit"
android:id="@+id/Button"
android:layout_width="wrap
android:layout_height="wra
android:layout_alignParent
android:layout_alignParent
</Button>
<EditText android:id="@+id/Edi
android:layout_width="matc
android:layout_height="wra
android:layout_toLeftOf="@
android:layout_alignParent
</EditText>
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="wrap_con
android:layout_height="0dp"
android:layout_weight="1" />
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 7/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="wrap_content
android:layout_height="fill_parent
android:layout_below="@+id/linearL
android:layout_centerHorizontal="t
android:orientation="horizontal"
android:gravity="bottom"
android:layout_alignParentBottom="
android:layout_marginTop="20dp"
>
<Button
android:id="@+id/button1"
android:layout_width="wrap_con
android:layout_height="wrap_co
android:text="Button"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_con
android:layout_height="wrap_co
android:text="Button"
/>
</LinearLayout>
12 android:layout_alignParentBottom="tr
ue" has no effect unless the
LinearLayout is nested inside a
RelativeLayout. – Thomas Dignan
Jan 18 '12 at 15:17
By using our site, you acknowledge that you have read and understand our , , and our
.
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 8/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
<Space
android:layout_width="match_parent
android:layout_height="match_paren
android:layout_weight="1" />
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 9/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
<LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="match_parent
android:layout_height="wrap_conten
android:orientation="horizontal"
app:layout_constraintBottom_toBott
</LinearLayout>
Just set
android:layout_gravity="bottom" in
your layout
<LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="match_parent
android:layout_height="wrap_conten
android:layout_gravity="bottom"
android:orientation="horizontal">
</LinearLayout>
(1)Set a layout
android:layout_weight="1" on the top
of the your Layout
<TextView
android:id="@+id/TextView"
android:layout_width="match_parent
android:layout_height="0dp"
android:layout_weight="1"
android:text="welcome" />
<LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="match_parent
android:layout_height="match_paren
android:gravity="bottom"
android:orientation="horizontal">
</LinearLayout>
And set
android:layout_alignParentBottom="tr
site, to
By using our ue" youlet the Layout that
acknowledge on the
you bottom of and understand our
have read , , and our
the .screen
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 10/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
<LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="match_parent
android:layout_height="wrap_conten
android:layout_alignParentBottom="
android:orientation="horizontal">
</LinearLayout>
OUTPUT
android:layout_weight="1"
<TextView android:text="@string/welcom
android:id="@+id/TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_conten
android:layout_weight="1">
</TextView>
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 11/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
Kiran Parmar
659 7 24
[ Layout XML ]
<RelativeLayout
xmlns:android="http://schemas.andr
xmlns:tools="http://schemas.androi
android:layout_width="fill_parent"
android:layout_height="fill_parent
android:background="@color/backgro
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="fill_par
android:layout_height="40dp"
android:background="#FF0000">
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_par
android:layout_height="40dp"
android:layout_alignParentBott
android:background="#FFFF00">
</RelativeLayout>
</RelativeLayout>
[ Screenshot ]
By using our site, you acknowledge that you have read and understand our , , and our
. this is helpful. Thanks!!
Hope
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 12/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
<Button
android:id="@+id/btn_back"
android:layout_width="100dp"
android:layout_height="80dp"
android:text="Back" />
<TextView
android:layout_width="match_pa
android:layout_height="0dp"
android:layout_weight="0.97"
android:gravity="center"
android:text="Payment Page" />
<LinearLayout
android:layout_width="match_pa
android:layout_height="wrap_co
<EditText
android:layout_width="wrap
android:layout_height="wra
android:layout_weight="1"/
<Button
android:layout_width="wrap
android:layout_height="wra
android:text="Submit"/>
</LinearLayout>
</LinearLayout>
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 13/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
android:layout_width="match_parent
android:layout_height="match_paren
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent
android:layout_height="wrap_conten
android:layout_alignParentBottom="
android:layout_gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<Button
android:id="@+id/setup_macroSa
android:layout_width="0dp"
android:layout_height="wrap_co
android:layout_weight="1"
android:text="Save" />
<Button
android:id="@+id/setup_macroCa
android:layout_width="0dp"
android:layout_height="wrap_co
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</RelativeLayout>
Use
android:layout_alignParentBottom="tr
ue" in your <RelativeLayout> .
<ScrollView>
|-- <RelativeLayout>
|-- acknowledge
By using our site, you <LinearLayout>
that you have read and understand our , , and our
.
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 14/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
First, apply
android:fillViewport="true" to the
ScrollView and then apply
android:layout_alignParentBottom="tr
ue" to the LinearLayout .
<ScrollView
android:layout_height="match_paren
android:layout_width="match_parent
android:scrollbars="none"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_pa
android:layout_height="wrap_co
<LinearLayout
android:orientation="horiz
android:layout_width="matc
android:layout_height="wra
android:gravity="center"
android:id="@+id/linearLay
android:layout_alignParent
</LinearLayout>
</RelativeLayout>
</ScrollView>
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 15/16
12/12/2018 android - How to align views at the bottom of the screen? - Stack Overflow
By using our site, you acknowledge that you have read and understand our , , and our
.
https://stackoverflow.com/questions/2386866/how-to-align-views-at-the-bottom-of-the-screen 16/16