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);
}
}
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>
The problem is that the text color of the TextView is wrong in Android API 10. The text color is always black.
screenshot: http://imgur.com/HDFOIJY
Anyway when in my app I use an AlertDialog (not custom) the text color changes properly between different android APIs.
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?
Thanks for your help
Set your text color in the
TextView
itself and you'll get the text color as per your requirement.Finally I got a solution. I found the answer looking at this file: sdk/platforms/android-10/data/res/values/themes.xml
I added
style="?android:attr/panelTextAppearance"
to the EditText.So the above piece of xml becomes: