I am trying to make a linear layout with 3 buttons, with center alignment.
However, after setting some of the weight and putting spaces in between, the last button have like 1/4 of it deleted from the layout, invisible and not clickable. The other parts work perfectly fine though.
Sorry its a new account so I couldn't embed the screenshot, instead please click the following link:
and please also see the code below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum="4">
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<!--Nesting Structured Layout-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:weightSum="10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:layout_weight="2">
<!--This is for the Start button-->
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:text="@string/starting_button"/>
<!--Spacing-->
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<!--This is for the Message button-->
<Button
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="@string/liitle_message_button"/>
<!--Spacing-->
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<!--This is for the Settings button-->
<Button
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="@string/settings_button"/>
</LinearLayout>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
What is the problem of the code which cause the problem? And is there any other better approach to achieve the same result?
P.S I am sorry that as a non-native English user, I apologize in advance for it might have loads of grammatical mistakes or asking in an impolite manner, please let me know if you feel offended.