gpt4 book ai didi

android - PreferenceFragment 中类别之间的分隔线

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:52:06 32 4
gpt4 key购买 nike

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

Settings

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

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

但我得到的只是空偏好:

My

那我该如何解决呢?

最佳答案

试试这个:

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

关于android - PreferenceFragment 中类别之间的分隔线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35601241/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com