gpt4 book ai didi

android - 类别偏好后的 Material 分隔线

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

我正在尝试用 Material 主题来设计我的偏好,并且快成功了。

我导入了以下内容:

compile 'com.android.support:preference-v7:25.1.0'
compile 'com.android.support:preference-v14:25.1.0'

然后在我的主应用主题中设置首选项主题:

<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>

而且我的首选项屏幕看起来还不错。我唯一的问题是这些类别的空间或视觉分离度为零,这使得所有偏好看起来非常杂乱无章。

Material 设计文档显示了一个分隔线,看起来像顶部和底部阴影(设备类别上方的 IE):

几个问题:

  1. android 有这个功能吗?如果有,是否有更新的 appcompat 主题?或者我做错了什么?

  2. 如果 android 还没有在 Material 偏好主题中提供这个分隔线,有人创建了吗?我看到了这个,他在其中创建了一个具有自定义布局的新类别,Divider between category in PreferenceFragment .但我不完全确定如何创建所需的效果。

最佳答案

另一个答案很好,在这里稍微编辑一下,以防您根本不理解可绘制对象。

xml/preferences.xml

<PreferenceCategory
android:layout="@layout/divider"
android:title="Category2">
<Preference
android:title="Test1"
android:summary="Summary1"/>

</PreferenceCategory>

layout/divider.xml

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


</LinearLayout>

drawable/shadow.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#1F000000"
android:endColor="@android:color/transparent"
android:angle="90" />
</shape>

关于android - 类别偏好后的 Material 分隔线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41911362/

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