Android: Dialogpreference Color/style?
Solution 1:
You can inherit defult themes when creating styles in Android.
Please read the documentation on Applying Styles and Themes specifically the section on inheritance
You should be able to take Theme.light and correct any issues that you have with it.
You may find that different vendors alter the themes on their devices so if you are targeting a broad range of hardware then you may be better creating a full theme to ensure that your app is consistent on all platforms.
UPDATE
As stated in this answer Consistent UI color in all Android devices there are public and non-public attributes. The answer provides a link to a list of public attributes however kernel.org is still down so you will need to dig through the source for core/res/res/values/public.xml
Solution 2:
You can specify style of DialogPreference
's dialog using android:alertDialogTheme
(supported starting from API 11
) them property of preferences activity:
<stylename="PreferencesActivityTheme"parent="@style/Theme.AppCompat.Light.DarkActionBar"><itemname="android:alertDialogTheme">@style/Theme.MyDialog</item></style><stylename="Theme.MyDialog"parent="@style/Theme.AppCompat.Light.Dialog"><itemname="colorPrimary">@color/colorPrimary</item><itemname="colorPrimaryDark">@color/colorPrimaryDark</item><itemname="colorAccent">@color/colorAccent</item></style>
Solution 3:
I have a solution how you can do it programmatically (I think its the easier way):
publicclassCustomDialogPreferenceextendsDialogPreference {
...
@OverrideprotectedvoidshowDialog(Bundle state) {
super.showDialog(state);
//changing color of dividerintdivierId= getDialog().getContext().getResources()
.getIdentifier("android:id/titleDivider", null, null);
Viewdivider= getDialog().findViewById(divierId);
divider.setBackgroundColor(getContext().getResources().getColor(R.color.light_orange));
//changing color of title textviewinttitleId= getDialog().getContext().getResources()
.getIdentifier("android:id/alertTitle", null, null);
TextViewtitle= (TextView) getDialog().findViewById(titleId);
title.setTextColor(getContext().getResources().getColor(R.color.light_orange));
}
...
}
Post a Comment for "Android: Dialogpreference Color/style?"