Android开对话文本颜色 [英] Android get Dialog text color
问题描述
我有一个自定义对话框preference:
I have a custom DialogPreference:
public class MyDiagPreference extends DialogPreference {
public MyDiagPreference(Context context, AttributeSet attrs) {
super(context, attrs);
this.setDialogLayoutResource(R.layout.my_diag_preference);
}
}
这是my_diag_ preference.xml:
This is my_diag_preference.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:orientation="vertical" >
<TextView
android:id="@+id/testTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test TextView" />
</LinearLayout>
现在的问题是,该TextView的文本颜色是错误的Android的API 10。 文本颜色始终是黑色的。
The problem is that the text color of the TextView is wrong in Android API 10. The text color is always black.
反正当我的应用程序我使用一个AlertDialog(不定制),文本颜色变化适当地不同的Android API之间。
Anyway when in my app I use an AlertDialog (not custom) the text color changes properly between different android APIs.
所以, 有没有办法通过XML来获得使用的对话文本的颜色,这样我就可以使用该值来设置我的EditText的colorText以上?
So, is there a way to get via xml the color of the text used by a Dialog, so that I can use that value to set the colorText of my EditText above?
感谢您的帮助
推荐答案
最后,我得到了一个解决方案。我找到了答案看这个文件: SDK /平台/ Android为10 /数据/ RES /价值/的themes.xml 的
Finally I got a solution. I found the answer looking at this file: sdk/platforms/android-10/data/res/values/themes.xml
我添加风格=机器人:ATTR / panelTextAppearance。
到的EditText
I added style="?android:attr/panelTextAppearance"
to the EditText.
所以上面的XML片段就变成了:
So the above piece of xml becomes:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:orientation="vertical" >
<TextView
android:id="@+id/testTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test TextView"
style="?android:attr/panelTextAppearance" />
</LinearLayout>
这篇关于Android开对话文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!