Baz*_*Baz 5 layout android android-preferences material-design
棒棒糖上的Android系统首选项屏幕似乎使用类似于"卡片布局"的布局.
我正在尝试为我的应用程序获得相同的外观,但无法看到他们如何使用默认值实现它PreferenceFragment.任何人都可以向我解释,如何在不写自己的偏好的情况下达到同样的效果?
请注意,我已经看过并阅读了这些问题,但它们没有提供合适的答案:
PreferenceFragment)PreferenceFragment)如果感兴趣,我当前的首选项xml如下所示:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/preferences_title_general">
<Preference
android:key="Prefs.Delete.Row.Token"
android:summary="@string/preferences_delete_row_token_summary"
android:title="@string/preferences_delete_row_token_title"/>
<Preference
android:key="Prefs.Delete.Cell.Token"
android:summary="@string/preferences_delete_cell_token_summary"
android:title="@string/preferences_delete_cell_token_title"/>
<Preference
android:key="Prefs.Null.Token"
android:summary="@string/preferences_null_token_summary"
android:title="@string/preferences_null_token_title"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/preferences_title_appearance">
<SwitchPreference
android:dialogTitle="@string/preferences_theme_title"
android:key="Prefs.Appearance.Theme"
android:summaryOff="@string/preferences_theme_summary_off"
android:summaryOn="@string/preferences_theme_summary_on"
android:switchTextOff="@string/general_no"
android:switchTextOn="@string/general_yes"
android:title="@string/preferences_theme_title"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/preferences_title_misc">
<SwitchPreference
android:dialogTitle="@string/preferences_read_back_title"
android:key="Prefs.Voice.Feedback"
android:switchTextOff="@string/general_no"
android:switchTextOn="@string/general_yes"
android:title="@string/preferences_read_back_title"/>
<Preference
android:key="Prefs.Export.Barcode.Properties"
android:title="@string/preferences_export_title"
android:summary="@string/preferences_export_summary"/>
<Preference
android:key="Prefs.Show.Eula"
android:title="@string/preferences_eula_title"
android:summary="@string/preferences_eula_summary"/>
</PreferenceCategory>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
我通过扩展PreferenceFragment和加载xml
addPreferencesFromResource(R.xml.prefs);
Run Code Online (Sandbox Code Playgroud)
我通过在使用布局的项目Preference之间添加一个虚拟对象来“解决”这个问题PreferenceCategory,该布局模仿问题中屏幕截图中的外观:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto">
<PreferenceCategory></PreferenceCategory>
<Preference layout="@layout/preference_divider" />
<PreferenceCategory></PreferenceCategory>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
布局看起来像这样:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1301 次 |
| 最近记录: |