android checkboxpreference属性,android – 具有自己布局的CheckBoxPreference

android checkboxpreference属性,android – 具有自己布局的CheckBoxPreference我有PreferenceScreen和一些PreferenceCheckBoxes.我想更改textColor和textSize的标题和摘要以及CheckBox的图像选中和取消选中.所以我使用android:layout来改变这个属性.我的ChceckBoxPreference:android:layout=”@layout/preference_checkbox”android:key=”tem…

我有PreferenceScreen和一些PreferenceCheckBoxes.我想更改textColor和textSize的标题和摘要以及CheckBox的图像选中和取消选中.所以我使用android:layout来改变这个属性.

我的ChceckBoxPreference:

android:layout=”@layout/preference_checkbox”

android:key=”temp”

android:title=”@string/title”

android:summary=”@string/summary”

android:defaultValue=”true”

/>

当我使用android:widgetLayout时,它看起来很奇怪.这是我的preference_checkbox.xml:

android:orientation=”horizontal”

android:layout_width=”fill_parent”

android:layout_height=”fill_parent”

android:padding=”10dp”

>

android:orientation=”vertical”

android:layout_width=”wrap_content”

android:layout_height=”fill_parent”

android:layout_alignParentLeft=”true”

android:layout_marginLeft=”10dp”

>

android:id=”@+android:id/title”

android:layout_width=”fill_parent”

android:layout_height=”wrap_content”

android:textColor=”@color/gray”

android:textSize=”20sp”

/>

android:id=”@+android:id/summary”

android:layout_width=”fill_parent”

android:layout_height=”wrap_content”

android:textColor=”@color/gray”

android:textSize=”14sp”

/>

android:id=”@+android:id/checkbox”

android:layout_width=”wrap_content”

android:layout_height=”fill_parent”

android:layout_alignParentRight=”true”

android:layout_marginRight=”10dp”

/>

标题为id @ android:id / title和摘要,@ android:id / summary显示正确的值.然而,尽管默认值和id @ android:id / checkbox复选框无法正常工作.它没有显示正确的值,我无法更改首选项中保留的值.

不使用任何布局,我可以通过触摸整个CheckBoxPreference来更改复选框的值.但现在(使用我的布局)我只能通过触摸此复选框来更改复选框的值.

如何以正确的方式为所有功能制作CheckBoxPreference的布局?

解决方法:

试试这个为preference_checkbox.xml

android:layout_width=”match_parent” android:layout_height=”wrap_content”

android:minHeight=”?android:attr/listPreferredItemHeight”

android:gravity=”center_vertical” android:paddingRight=”?android:attr/scrollbarSize”>

android:layout_height=”wrap_content” android:layout_marginLeft=”15dip”

android:layout_marginRight=”6dip” android:layout_marginTop=”6dip”

android:layout_marginBottom=”6dip” android:layout_weight=”1″>

android:layout_width=”wrap_content” android:layout_height=”wrap_content”

android:singleLine=”true” android:textAppearance=”?android:attr/textAppearanceLarge”

android:ellipsize=”marquee” android:fadingEdge=”horizontal”

android:textColor=”#FF0000″ />

android:layout_width=”wrap_content” android:layout_height=”wrap_content”

android:layout_below=”@android:id/title” android:layout_alignLeft=”@android:id/title”

android:textAppearance=”?android:attr/textAppearanceSmall”

android:maxLines=”4″ />

android:layout_width=”wrap_content” android:layout_height=”match_parent”

android:gravity=”center_vertical” android:orientation=”vertical” />

标签:android,android-preferences,checkboxpreference

来源: https://codeday.me/bug/20190928/1828194.html

今天的文章android checkboxpreference属性,android – 具有自己布局的CheckBoxPreference分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:http://bianchenghao.cn/23755.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注