Difficulty in hitting the buttons in the layout

0

I can not put the buttons in the layout as I want. I wanted to leave a button in the center and the others in the bottom (bottom) of what is in the center. So they are not correct and I can not get it right when the resolution changes.

<LinearLayout
    android:orientation="vertical"
    android:layout_height="match_parent"
    android:weightSum="1"
    android:layout_width="match_parent"
    android:gravity="center">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="523dp"
        android:gravity="bottom|center">

        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/button10"
            android:layout_weight="1"
            android:background="@drawable/hohoho" />
    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="99dp"
        android:gravity="top">

        <Button
            android:text="Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/button9"
            android:layout_weight="1" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/button8"
            android:layout_weight="1" />
    </LinearLayout>
</LinearLayout>

    
asked by anonymous 25.11.2016 / 17:42

1 answer

0

Your "bigger" layout has to have a weightSum of 2, because inside it has 2 other layouts. These two smaller layouts must be RelativeLayout with the layout_weight attribute of 1 each layout, to total the sum of value 2. In this way, the screen will be split in half perfectly. So inside the layout above you poe the button and puts the gravity of the layout to throw everything down. In the bottom layout, you put the buttons and put the gravity up. Home Thus, all buttons will be perfectly centered regardless of screen size.

    
25.11.2016 / 18:43