有没有人知道xml主题/样式中的哪个参数负责PreferenceScreen弹出窗口中的文本颜色? 为了说明:
文字颜色是黑色的,所以我试过的样式属性不受影响。这个背景是白色的,但后来我想把它改成黑暗的东西,我也需要改变文字的颜色。
PreferenceScreen片段。
public final class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
// setting style of the preference screen
this.getActivity().setTheme(R.style.Theme_Preference_Screen);
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
// I'm setting background color to make cover for activity behind preference screen
if (view != null) {
view.setBackgroundColor(ContextCompat.getColor(this.getActivity(), R.color.colorNavyBlue));
}
return view;
}
我分配给首选项屏幕的样式。之后< item name =“colorButtonNormal”> @ color / colorJewel< /项目>休息是多余的,但我想把它留在这里,所以你可以看到我尝试了哪一个。
<style name="Theme_Preference_Screen" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorPrimary">@color/colorJewel</item>
<item name="colorPrimaryDark">@color/colorVoid</item>
<item name="colorAccent">@color/colorFuschia</item>
<item name="android:background">@color/colorVoid</item>
<item name="android:textColor">@color/colorStark</item>
<item name="android:listDivider">@color/colorStark</item>
<item name="android:editTextColor">@color/colorStark</item>
<item name="colorButtonNormal">@color/colorJewel</item>
<item name="android:textColorSecondary">@color/colorStark</item>
<item name="android:actionMenuTextColor">@color/colorStark</item>
<item name="android:textColorAlertDialogListItem">@color/colorStark</item>
<item name="android:textColorHighlight">@color/colorStark</item>
<item name="android:textColorHint">@color/colorStark</item>
<item name="android:keyTextColor">@color/colorStark</item>
<item name="android:textAppearanceLargePopupMenu">@color/colorStark</item>
<item name="android:textAppearanceSmallPopupMenu">@color/colorStark</item>
<item name="android:textColorLink">@color/colorStark</item>
</style>
答案 0 :(得分:0)
我只是成功将ListPreference(例如在R.xml.preference中)更改为com.afollestad.materialdialogs.prefs.MaterialListPreference from Material-dialogs liberary。然后弹出窗口从我的主题中选择了背景颜色。