Java 更改EditTextPreference对话框输入文本颜色
我可以更改编辑文本首选项的标题和摘要颜色。当你点击它时,我的背景是黑色的,按钮是白色的。我仍然需要弄清楚如何更改文本的实际值。有什么想法吗 如果我也能改变那条线的颜色那就太好了 我的风格是:Java 更改EditTextPreference对话框输入文本颜色,java,android,colors,edittextpreference,Java,Android,Colors,Edittextpreference,我可以更改编辑文本首选项的标题和摘要颜色。当你点击它时,我的背景是黑色的,按钮是白色的。我仍然需要弄清楚如何更改文本的实际值。有什么想法吗 如果我也能改变那条线的颜色那就太好了 我的风格是: <style name="JayPreferenceThemeDialog" > <item name="android:colorBackground">@color/THEME_LIGHTER_BACKGROUND</item> <item
<style name="JayPreferenceThemeDialog" >
<item name="android:colorBackground">@color/THEME_LIGHTER_BACKGROUND</item>
<item name="android:textColor">@android:color/background_light</item>
<item name="android:textColorSecondary">@android:color/background_light</item>
</style>
@颜色/主题\u颜色较浅\u背景
@android:颜色/背景光
@android:颜色/背景光
试试这个:
<style name="JayPreferenceThemeDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/colorAccent</item> //line color
<item name="android:colorBackground">@color/THEME_LIGHTER_BACKGROUND</item>
<item name="android:textColor">@android:color/background_light</item>
<item name="android:textColorSecondary">@android:color/background_light</item>
</style>
@颜色/颜色重音//线条颜色
@颜色/主题\u颜色较浅\u背景
@android:颜色/背景光
@android:颜色/背景光
来自热心共享链接:
使用新的字体资源,而不是这里提供的旧methodTry解决方案-
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="6"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<style name="JayPreferenceThemeDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/colorAccent</item> //line color
<item name="android:colorBackground">@color/THEME_LIGHTER_BACKGROUND</item>
<item name="android:textColor">@android:color/background_light</item>
<item name="android:textColorSecondary">@android:color/background_light</item>
</style>
@Override
protected void showDialog(Bundle state) {
super.showDialog(state);
Typeface customFont = FontCache.getTypeface("UnderwoodChampionRegular.ttf", GameActivity.commandReceiver.activity_settings);
final Resources res = getContext().getResources();
final Window window = getDialog().getWindow();
// Title
final int titleId = res.getIdentifier("alertTitle", "id", "android");
final View title = window.findViewById(titleId);
if (title != null) {
((TextView) title).setTextColor(ContextCompat.getColor(MyCommandReceiver.context_settings, R.color.THEME_LIGHT_TEXT));
((TextView) title).setTypeface(customFont);
}
// Title divider
final int titleDividerId = res.getIdentifier("titleDivider", "id", "android");
final View titleDivider = window.findViewById(titleDividerId);
if (titleDivider != null) {
titleDivider.setBackgroundColor(ContextCompat.getColor(MyCommandReceiver.context_settings, R.color.THEME_LIGHT_TEXT));
}
// EditText
final View editText = window.findViewById(android.R.id.edit);
if (editText != null) {
((EditText) editText).setTextColor(ContextCompat.getColor(MyCommandReceiver.context_settings, R.color.THEME_LIGHT_TEXT));
((EditText) editText).setTypeface(customFont);
}
//OK button
final View okButton = window.findViewById(android.R.id.button1);
if (okButton != null) {
((Button) okButton).setTextColor(ContextCompat.getColor(MyCommandReceiver.context_settings, R.color.THEME_LIGHT_TEXT));
((Button) okButton).setTypeface(customFont);
}
//Cancel button
final View cancelButton = window.findViewById(android.R.id.button2);
if (cancelButton != null) {
((Button) cancelButton).setTextColor(ContextCompat.getColor(MyCommandReceiver.context_settings, R.color.THEME_LIGHT_TEXT));
((Button) cancelButton).setTypeface(customFont);
}
}