2

Does the gravity setting set by the parent override all layout_gravity settings set by its children? It seems to when I try it. Is there a way to bypass this behaviour? I would like to use a LinearLayout with a global gravity, but I want one element to be aligned to the bottom always.

I don't want a RelativeLayout.

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

    <TextView
        android:id="@+id/textview_error_message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <Button
        android:id="@+id/button_next"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:text="@string/button_next" />
</LinearLayout>
Vas
  • 2,014
  • 3
  • 22
  • 38
  • Possible duplicate of [Gravity and layout\_gravity on Android](http://stackoverflow.com/questions/3482742/gravity-and-layout-gravity-on-android) – OneCricketeer Jun 10 '16 at 23:48
  • At the bottom of the screen? – Salman Tariq Jun 10 '16 at 23:50
  • If you want it all the way to the bottom but your parent `Layout` does not reach the bottom maybe you will want to put that component (your button) inside another `Layout` that does reach the bottom (that is, move your Button Outside that Layout). Hope it helps – DarkCygnus Jun 11 '16 at 00:03

0 Answers0