11

Just a quick simple question, I am using CheckedTextView and I was wondering what, if any, line of code I could use to place the check box on the left side instead of the right side.

Here is my current CheckedTextview Code:

<CheckedTextView
    android:id="@+id/ootChild"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="25dp"
    android:textSize="17sp"
    android:checkMark="@drawable/btn_check_off"
    android:clickable="true"
    android:checked="false" 
    android:onClick="toggle"/>

If there isn't an easy or quick way to do it I can always just use a CheckBox and TextView and place them how I want them.

Mowza2k2
  • 123
  • 1
  • 11
  • http://stackoverflow.com/questions/19228542/how-to-align-the-checkboxes-in-the-checkedtextview-in-android – ngrashia Jun 04 '14 at 06:56
  • http://stackoverflow.com/questions/3114745/how-do-i-make-the-checkbox-in-android-checkedtextview-be-left-aligned-instead-of – ngrashia Jun 04 '14 at 06:56

3 Answers3

27

Add android:drawableLeft="?android:attr/listChoiceIndicatorMultiple" as an XML attribute on your CheckedTextView. You can add android:drawableLeft="?android:attr/listChoiceIndicatorSingle" to see a radio instead of a checkbox.

CodeMonkey
  • 1,426
  • 1
  • 14
  • 32
0

Add android:layoutDirection="rtl" So the code in the question becomes:

<CheckedTextView
android:id="@+id/ootChild"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:textSize="17sp"
android:checkMark="@drawable/btn_check_off"
android:clickable="true"
android:checked="false"
android:layoutDirection="rtl" 
android:onClick="toggle"/>
Rediska
  • 1,392
  • 10
  • 14
  • 1
    Answer needs supporting information Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](https://stackoverflow.com/help/how-to-answer). – moken Jul 24 '23 at 07:24
-1

Use the following syntax:

<CheckedTextView
    android:id="@+id/ootChild"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="25dp"
    android:textSize="17sp"
    android:checkMark="@drawable/btn_check_off"
    android:clickable="true"
    android:checked="false"
    android:onClick="toggle"
    android:drawableLeft="?android:attr/listChoiceIndicatorMultiple" />
Ε Г И І И О
  • 11,199
  • 1
  • 48
  • 63