By default, views in a vertical LinearLayout are measured and layouts from top to bottom, just as on horizontal one from left to right.
Usually, if I want to have a layout that has its children measured from bottom to top, I usually use RelativeLayout, with an id for each of the children, while the bottom view has layout_alignParentBottom set to true, and the rest have "layout_above" set to the view below them:
<RelativeLayout>
<View android:id="@+id/bottomView android:layout_alignParentBottom="true" />
<View android:id="@+id/secondView android:layout_above="@+id/bottomView " />
<View android:id="@+id/thirdView android:layout_above="@+id/secondView " />
...
</RelativeLayout
But this is annoying to set, and can have issues if being added into another layout.
Is it possible to have this behavior on LinearLayout? The only thing I've found is LayoutDirection, but this seems to belong to RTL direction (horizontal), so it doesn't work.
Just set android:gravity="bottom" for your LinearLayout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With