问题
I have a scrollView
containing a form composed by multiple CheckedTextView
, my problem is that the check boxes of these ones are not in the same level, they are at this end of every text, what i want is to have them aligned so it looks good as a form. How to do that? i've been searching for hours but nothing yet.
how i have them :
blablablablablabla x
blablablablablablablablablablablabla x
blabla x
how i want them :
blablablablablabla x
blablablablablablablablablablablabla x
blabla x
回答1:
This may solve the purpose
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<CheckedTextView
android:id="@+id/my_checkedtextview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:checked="true"
android:clickable="true"
android:gravity="left|center_vertical"
android:hint="My text one" />
<CheckedTextView
android:id="@+id/my_checkedtextview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:checked="true"
android:clickable="true"
android:gravity="left|center_vertical"
android:hint="Trying a larger text " />
<CheckedTextView
android:id="@+id/my_checkedtextview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:checked="true"
android:clickable="true"
android:gravity="left|center_vertical"
android:hint="Checked" />
<CheckedTextView
android:id="@+id/my_checkedtextview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:checked="true"
android:clickable="true"
android:gravity="left|center_vertical"
android:hint="text with some more text" />
<CheckedTextView
android:id="@+id/my_checkedtextview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:checked="true"
android:clickable="true"
android:gravity="left|center_vertical"
android:hint="Checked" />
<CheckedTextView
android:id="@+id/my_checkedtextview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:checked="true"
android:clickable="true"
android:gravity="left|center_vertical"
android:hint="Checked" />
</LinearLayout>
</ScrollView>
Also attached the output.
回答2:
As a solution, I used single checkboxes
and textviews
来源:https://stackoverflow.com/questions/19228542/how-to-align-the-checkboxes-in-the-checkedtextview-in-android