I have a ListView whereby each row contains a CheckedTextView. I am using a custom checkMark attribute, which uses a drawable:
<CheckedTextView
android:id="@+id/body"
android:gravity="left"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_below="@+id/date"
android:textSize="18sp"
android:checkMark="@drawable/checkbox_selector"
/>
The drawable checkbox_selector correctly handles the 'on' and 'off' selection as expected and is as follows:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_selected="true" android:state_pressed="true"
android:drawable="@drawable/checkbox_on" >
</item>
<item android:state_pressed="true" android:drawable="@drawable/checkbox_on" />
<item android:state_checked="true" android:drawable="@drawable/checkbox_on"/>
<item android:drawable="@drawable/checkbox_off" />
</selector>
Here is a screenshot of the current ListView layout:
As you can see, the check box is top aligned. Is there any way to right-center it? Checking attributes of the selector resource, I can't find any relevant attributes to perform this.
Is there any way I could adjust its position? Thank you for your time.
Try this.
<CheckedTextView
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="@drawable/checkbox_selector"
android:checked="false"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:onClick="toggle"
android:text="Some text here"
android:textSize="18sp" />
Maybe add "center_vertical".
android:gravity="center_vertical"
ref: http://developer.android.com/reference/android/widget/LinearLayout.html`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With