PreferenceFragment中类别之间的分隔线 [英] Divider between category in PreferenceFragment
本文介绍了PreferenceFragment中类别之间的分隔线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试实现设置"应用的外观,这意味着我正在寻找在类别之间添加分隔符的解决方案.
I'm trying to achieve Settings app look, which means I'm looking for solution to add divider between categories.
所以我以为我找到了解决方案,但不幸的是,它对我不起作用.如建议的那样,我应该在布局中添加空的首选项:
So I thought I found solution, but unfortunately it's not working for me. As was suggested I should add empty preference with layout:
</PreferenceCategory>
<Preference
android:title="Test"
android:summary="Summary"/>
</PreferenceCategory>
<Preference layout="@layout/divider_preference" />
<PreferenceCategory
android:title="Category"/>
这里是分隔线:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="10dp"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/shadow_bottom"/>
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/shadow_top"/>
</LinearLayout>
但是我得到的只是空的偏好:
But what I get is just empty preference:
那我该如何解决呢?
推荐答案
尝试一下:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:layout="@layout/divider_preference"
android:title="Category1">
<Preference
android:title="Test"
android:summary="Summary"/>
</PreferenceCategory>
<PreferenceCategory
android:layout="@layout/divider_preference"
android:title="Category2">
<Preference
android:title="Test1"
android:summary="Summary1"/>
</PreferenceCategory>
</PreferenceScreen>
这篇关于PreferenceFragment中类别之间的分隔线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文