Android 使复选框看起来像复选框首选项
我希望能够在PreferenceFragment之外使用CheckboxPreference 如何使我的复选框看起来像复选框 主要是我希望复选框在右边。我尝试将样式设置为Android 使复选框看起来像复选框首选项,android,android-checkbox,preferencefragment,Android,Android Checkbox,Preferencefragment,我希望能够在PreferenceFragment之外使用CheckboxPreference 如何使我的复选框看起来像复选框 主要是我希望复选框在右边。我尝试将样式设置为@style/Preference.Checkbox。但这不起作用 <CheckBox android:id="@+id/map_shown" android:layout_width="wrap_content" android:layout_height="wrap_content" a
@style/Preference.Checkbox
。但这不起作用
<CheckBox
android:id="@+id/map_shown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/spacing_extra_small"
android:onCheckedChanged="@{ (switch, checked) -> event.setMapShown(checked) }"
style="@style/Preference.CheckBoxPreference"
android:text="@string/show_map" />
我需要这个看起来像:
<android.support.v7.preference.CheckBoxPreference
android:key="map_shown"
android:title="Show Map"
android:summaryOff="Map is shown"
android:summaryOn="Map is not shown"
android:defaultValue="false"/>
将复选框右侧对齐到
文本视图,然后尝试使用
希望它能帮助你 共享您的代码。@HemantParmar我认为代码应该是无关的,但我已经共享了代码。您必须扩展“设置自定义属性”复选框。您的代码只更改背景。我不想改变背景。我只希望我的复选框看起来像首选项复选框(右边有复选框),即设置中的复选框。还有,没有办法不扩展复选框(比如使用样式)?右边有复选框??你能详细解释一下吗?你一定在应用程序中见过设置活动(PreferenceFragment或PreferenceActivity)。首选项复选框的复选框位于右侧,文本位于左侧。然而,普通复选框小部件的复选框在左边,文本在右边。ohk意味着您希望复选框在右边,文本在左边??是的,连同摘要,如果可能的话,以干净的方式,而不必扩展基类。
<CheckedTextView
android:id="@+id/checkedTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:checked="true"
android:text="CheckedTextView" />