【问题标题】:Divider between category in PreferenceFragmentPreferenceFragment 中类别之间的分隔符
【发布时间】:2016-06-06 16:32:17
【问题描述】:

我正在尝试实现“设置”应用外观,这意味着我正在寻找在类别之间添加分隔符的解决方案。

所以我以为我找到了解决方案,但不幸的是它对我不起作用。正如建议的那样,我应该在布局中添加空首选项:

</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>

但我得到的只是空洞的偏好:

那我该如何解决呢?

【问题讨论】:

  • 偏好类别之间的分界线。
  • 设置应用中的图片显示了我想要的内容
  • 以上布局你实现了吗?您能否包含阴影背景以提供完整的解决方案。

标签: android preferencefragment


【解决方案1】:

试试这个:

<?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>

【讨论】:

  • 我使用@layout/divide_preference 在我的类别之间添加了空的偏好类别,但我给了我提示。谢谢!
  • 这对我不起作用,“@layout/divider_preference”无法解决。由于某种原因,这没有定义。我正在使用 PreferenceFragment...
猜你喜欢
  • 2015-03-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-23
  • 2011-11-12
相关资源
最近更新 更多