<ListPreference android:defaultValue="1" android:dialogTitle="dialogTitle" android:entries="@array/entries" android:entryValues="@array/entryValues" android:key="key" android:title="@string/Title" /> 
  • The answer can be found in about 13 seconds in Google. On request android listpreference style - Vladyslav Matviienko
  • Google taxis! It's a pity I was looking for in Yandex, although at the same request! - Stanislav Derepovsky
  • one
    I may surprise you, but in Google you can find answers to 98% of the questions asked here, spending no more than 30 seconds - Vladyslav Matviienko

1 answer 1

 <com.your.domain.ThemedListPreference android:defaultValue="1" android:dialogTitle="@string/select_type" android:entries="@array/pref_secur_titles" android:entryValues="@array/pref_secur_values" android:key="key" android:theme="@style/ListPreferenceTheme" android:title="Title" /> 

Create a new class, for example ThemedListPreference:

 import android.content.res.TypedArray; import android.view.ContextThemeWrapper; import android.util.AttributeSet; import android.content.Context; import android.preference.ListPreference; public class ThemedListPreference extends ListPreference { private static int[] ATTRS = { android.R.attr.theme }; private ContextThemeWrapper mContextWrapper; public ThemedListPreference(Context context){ this(context, null); } public ThemedListPreference(Context context, AttributeSet attrs){ super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mContextWrapper = new ContextThemeWrapper(context, a.getResourceId(0, 0)); a.recycle(); } @Override public Context getContext(){ return mContextWrapper; } } 

Add to style.xml:

 <style name="ListPreferenceTheme" parent="android:Theme.Material.Light"> <item name="android:colorPrimary">@color/primary</item> <item name="android:colorPrimaryDark">@color/accent</item> <item name="android:colorAccent">@color/accent</item> <item name="android:dialogTheme">@style/DialogStyle</item> <item name="android:alertDialogTheme">@style/DialogStyle</item> </style> <style name="DialogStyle" parent="android:Theme.Material.Light.Dialog"> <item name="android:colorAccent">@color/accent</item> </style>