lundi 14 novembre 2016

Android: how do I horizontally align Checkbox with TextView text when underlined?

I have a TextView line where each character is underlined. I would like the bottom of the Checkbox (to the left) to be perfectly horizontally aligned with bottom of the text on the TextView line.

Right now the Checkbox is pushed down a bit below the bottom of the "3447Test" TextView line. Maybe due to the underline of the text? I tried adding "android:gravity="center_vertical" to the Checkbox and the TextView ("cardBlankText2") but no luck. What am I missing?

misaligned Checkbox relative to the TextView:

enter image description here

layout file:

...
<CheckBox
        android:id="@+id/chkSelected"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:gravity="center_vertical"
        android:layout_below="@+id/cardBlankText1"
        android:layout_above="@+id/cardBlankText4"
        android:layout_marginStart="2dp"
        android:layout_marginLeft="2dp"
        android:clickable="false"
        android:focusable="false"  />

    <TextView
        android:id="@+id/cardBlankText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/chkSelected"
        android:layout_toEndOf="@+id/chkSelected"
        android:layout_below="@+id/cardBlankText1"
        android:layout_marginLeft="4dp"
        android:layout_marginStart="4dp"
        android:text="todo"
        android:textColor="@android:color/black"
        android:textStyle="bold"
        android:layout_marginBottom="5dp"
        android:background="@drawable/todo_underline"
        android:maxLines="1"
        style="@style/Base.TextAppearance.AppCompat.Headline"
        android:clickable="true"  />




Aucun commentaire:

Enregistrer un commentaire