自定义首选项中的android首选项水平分隔线?
我创建了自己的自定义首选项对象来扩展首选项。我创建它们只是因为这些自定义数据类型没有首选项。
一切正常,但我的自定义首选项没有相同的外观,因为它们缺少系统首选项对象具有的水平分隔线。我已经查找了创建水平分隔线的代码,但我找不到它是在哪里完成的。
内置分隔板不仅仅是一根细条。它有一点梯度。我认为这可能在布局文件中,但我找不到系统首选项的布局。
有人知道这是如何实现的吗?
I've created my own custom preference objects that extend Preference. I've only created them because there are no Preferences for these custom data types.
Everything is working, but my custom preferences don't have the same appearance because they are missing the horizontal divider that the system preference objects have. I've looked for the code that is creating the horizontal divider, but I can't find where it is done.
The built in divider isn't just a thin bar. There is a bit of a gradient to it. I'm thinking that this may be in a layout file, but I can't find the layouts for the system preferences.
Anybody got an idea how this is implemented?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很旧的帖子,但对于那些偶然发现这一点的人来说。不确定 OP 是否询问如何更改分隔线或分隔线图像来自哪里。所以我会解决这两个问题。
如何
Preferences
使用ListView
来填充所有单独的首选项。这意味着您可以使用ListView
中的.setDivider()
方法更改分隔线。PreferenceActivity
已经为您提供了getListView()
方法。但是对于PreferenceFragments
只需使用android.R.id.list
ID 即可找到它。如果您不想通过代码更改分隔线,则始终可以通过覆盖
listDivider
属性来使用主题。例如:请注意,这将更改应用程序中每个
ListView
的分隔线。地点
使用的 listDivider 可绘制对象取决于激活的 Android 主题。您可以在已安装的 Android SDK 中的以下位置找到所有这些图像:
[Android SDK]/platforms/[API]/data/res/drawable-[DPI]/
只需搜索“*divider_horizontal*”,您就会找到很多。它们有九个补丁,并且并非全部都是纯色。
Very old post, but to those who stumble upon this. Wasn't sure if the OP was asking how to change the divider or where the divider images come from. So I'll address both.
How
Preferences
uses aListView
for populating all the individual preferences. That means you can change the divider by using the.setDivider()
method fromListView
. APreferenceActivity
will already have thegetListView()
method for you. However forPreferenceFragments
just use theandroid.R.id.list
ID to find it.If you don't want to change the divider through code, you can always use a theme by overriding the
listDivider
attribute. Eg:Note, that will change the divider for EVERY
ListView
in your app.Where
The listDivider drawable used depends on what Android theme is activated. You'll find all these images in the installed Android SDK at this location:
[Android SDK]/platforms/[API]/data/res/drawable-[DPI]/
Just do a search for `*divider_horizontal*`, and you'll turn up quite a few. They are nine-patched and not all of them are solid colors.