los*_*ion 9 android android-preferences android-layout android-view material-design
我试图用物质主题来塑造我的喜好,而且几乎就在那里.
我导入了以下内容:
compile 'com.android.support:preference-v7:25.1.0'
compile 'com.android.support:preference-v14:25.1.0'
Run Code Online (Sandbox Code Playgroud)
然后在我的主应用主题中设置首选项主题:
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
Run Code Online (Sandbox Code Playgroud)
我的偏好屏幕看起来很不错.我唯一的问题是类别没有空间或视觉分离,使得所有偏好看起来非常混乱.
材质设计文档显示的分隔符看起来像顶部和底部阴影(设备类别上方的IE):
几个问题:
android提供这个吗?如果有,那么有更新的appcompat主题吗?或者其他我做错了什么?
如果android尚未在材质首选项主题中提供此分隔符,那么有人创建了它吗?我看到了这一点,他创建了一个带有自定义布局的新类别,PreferenceFragment中的类别之间的Divider.但我不完全确定如何创造所需的效果.
另一个答案很好,稍稍编辑它,以防你只是不理解drawable.
XML /的preferences.xml
<PreferenceCategory
android:layout="@layout/divider"
android:title="Category2">
<Preference
android:title="Test1"
android:summary="Summary1"/>
</PreferenceCategory>
Run Code Online (Sandbox Code Playgroud)
布局/ 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>
Run Code Online (Sandbox Code Playgroud)
绘制/ 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>
Run Code Online (Sandbox Code Playgroud)