I have a linearlayout
and I want to create at the bottom of it a slice.
I know there are some options, but I'm a bit confused
1) android:layout_gravity:"bottom" --> this doesn't work for me for some reason.
2) android:gravity_weight="0" and give the sibling before it android:gravity_weight:"1" 
3) android:height="wrap_content" and give the sibling before it android:height:"match_parent"
I know how to do this using relativeLayout, but I want to practice linearLayout
what would you suggest?
<?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/blue_bg"
    android:orientation="vertical" >
   <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="5dp"
        android:src="@drawable/signup_illu_why" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight=""
        android:orientation="horizontal" />
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/signup_skip_icon" />
</LinearLayout>
                If you have a relative layout that fills the whole screen you should be able to use android:layout_alignParentBottom to move the button to the bottom of the screen.
You can set the layout_height="0dp" of your header, footer and ScrollView and define a layout_weight . Just play around with the values until you find out which works best. The resulting heights of header and footer would dynamically change with the screensize.
To create a linear layout in which each child uses the same amount of space on the screen, set the android:layout_height of each view to "0dp" (for a vertical layout) or the android:layout_width of each view to "0dp" (for a horizontal layout). Then set the android:layout_weight of each view to "1" .
How do you align buttons in relative layout? The 2 buttons are placed below the TextView having id textView. This is done by using the android:layout_below="@+id/textView" attribute in both the Button tags.
<LinearLayout
    android:orientation="vertical"
                              ... >
    <Space
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
    <SomeViewThatNeedsGoBottom
                             ... />
</LinearLayout>
                        Actually, you can set the parent element's gravity to bottom
<?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/blue_bg"
    android:orientation="vertical"
    android:gravity="bottom" >
   <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="5dp"
        android:src="@drawable/signup_illu_why" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight=""
        android:orientation="horizontal" />
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/signup_skip_icon" />
</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