I have the following code -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="HardcodedText">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"/>
</LinearLayout>
It gives me this output -
Now including the code -
android:gravity="fill"
or
android:gravity="fill_horizontal"
or
android:gravity="fill_vertical"
doesn't bring about any change in the output.
As I understand from some tutorials -
fill
is used to fill the entire container both horizontally and verticallyfill_horizontal
is used to fill the entire container horizontallyfill_vertical
is used to fill the entire container vertically
Here, the container of LinearLayout
is supposed to be the whole screen as layout_width
and layout_height
is set as match_parent
So why the gravity codes fail to have any impact?