I'm struggling with aligning checkboxes in a table row in a layout described below. Where do I go wrong?
You can see in the picture that checkboxes are aligned to the left, and I want them in the center.
I tried all the features in layout-gravity, also tried to put the checkbox inside of another layout, but nothing helped.
The xml looks like this:
<!-- TABLE -->
<TableLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_top_margin"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<!-- HEADER -->
<TableRow android:background="@drawable/table_border_header">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/table_border_header"
android:padding="4dp"
android:text="HEADER 1"
android:textAlignment="textStart"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/table_border_header"
android:padding="4dp"
android:text="HEADER 2"
android:textAlignment="center"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/table_border_header"
android:padding="4dp"
android:text="HEADER 3"
android:textAlignment="center"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:textStyle="bold" />
</TableRow>
<!-- SECOND ROW -->
<TableRow android:background="@drawable/table_border">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/table_border"
android:padding="4dp"
android:text="SEED 1"
android:textAlignment="textStart"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" />
<CheckBox
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:background="@drawable/table_border"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" />
<CheckBox
android:layout_width="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:background="@drawable/table_border"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" />
</TableRow>
</TableLayout>
Aucun commentaire:
Enregistrer un commentaire