Red M
Red M

Reputation: 2799

Text underneath the android checkbox

I'm aware that we can have a Checkbox with an independent textView underneath it, but can we have a text that is part of a checkbox appearing it underneath the checkbox box?

If yes, can it be achieved through Android UI instead of doing it programmatically?

Upvotes: 0

Views: 1355

Answers (1)

beeb
beeb

Reputation: 1615

It is possible by using CheckedTextView:

<CheckedTextView
    android:drawableTop="@drawable/checkmark"
    android:checked="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Checked text"/>

And a selector:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/unchecked" android:state_checked="false"></item>
<item android:drawable="@drawable/checked"></item></selector>

Upvotes: 2

Related Questions