La schermata delle preferenze di sistema di Android su lecca-lecca sembra utilizzare un layout che assomiglia al "layout della carta".Come visualizzare le preferenze di sistema Android?
che sto cercando di ottenere lo stesso aspetto per la mia app, ma non può vedere come si è raggiunto con il default PreferenceFragment
. Qualcuno può spiegarmi come posso ottenere lo stesso effetto senza dover scrivere le mie preferenze personali?
Si noti che ho visto e letto queste domande, ma non forniscono una risposta adeguata:.
- How to achieve preference category cards like Android System Settings (Risposta mostra semplicemente come creare un layout che sembra simile non ha nulla da fare con
PreferenceFragment
) - Android Lollipop Sections Separator/Divider (si riferisce alle preferenze screenshot, ma OP non sembra voler applicare a
PreferenceFragment
)
Se è di interesse, il mio attuale preferenze XML assomiglia a questo:
<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>
ed estendo PreferenceFragment
e caricare il file XML tramite
addPreferencesFromResource(R.xml.prefs);
non hanno alcun api 20 dispositivo> a portata di mano, hai provato guardando con il monitor del dispositivo -> Dump vista gerarchia? –
@DavidMedenjak Ciò mi dà una gerarchia di layout. Ora cosa faccio con quello? Come ho detto, non sto cercando di riprodurre la struttura del layout in un layout normale, ma preferisco che il mio preferenceFragment esistente sia lo stesso. – Baz