Reputation: 2185
I'm attempting to create my first Android app and I'd like to horizontally align the items on screen and in rows.
I've tried setting the layout_gravity to center_horizontal as shown below however that doesn't appear to do anything. What am I missing?
Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wear.widget.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/box_inset_layout_padding"
tools:deviceIds="wear">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/inner_frame_layout_padding"
app:boxedEdges="all"
android:minWidth="25px"
android:minHeight="25px">
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="8"
android:layout_gravity="center_horizontal"
android:columnCount="1"
android:orientation="horizontal">
<TextView
android:id="@+id/text"
android:visibility="visible"
android:textSize="9dp"
android:layout_row="1"/>
<TextView
android:id="@+id/text2"
android:visibility="visible"
android:text="@string/hello_world"
android:textAlignment="center"
android:textSize="9dp"
android:layout_row="2"/>
<TextView
android:id="@+id/serviceScore"
android:layout_row="4"
android:visibility="visible"
android:textAlignment="center"
android:textSize="50dp"/>
</GridLayout>
</FrameLayout>
</android.support.wear.widget.BoxInsetLayout>
UI:
Upvotes: 0
Views: 126
Reputation: 1432
Greet by Nice! Just add Gravity of layout center instead of center_horizontal of GridLayout.
android:layout_gravity="center"
Upvotes: 1