Ich benutze Android-Support-Bibliothek, die Version weiß ich nicht, weil ich nicht weiß, wie man es überprüft. Das Problem, dem ich gegenüberstehe, ist offenbar der Wert für das android: textColor-Attribut. Wenn ich einen Stil definiere und ihn textAppearance von EditText zuweiße, wird die Farbe textColor ignoriert.Warum wird textColor in android: textAppearance ignoriert?
Also, ich habe eine folgende Layout:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- This text should be red, but it is black -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text color via TextAppearance"
android:textAppearance="@style/TextAppearance.EditText" />
<!-- The hint should be green, but it is grey -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hint color via TextAppearance"
android:textAppearance="@style/TextAppearance.EditText" />
<!-- Text is red as set in android:textColor -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text color via android:textColor"
android:textColor="#880000"
android:textSize="18sp" />
<!-- Hint is green as set in android:textColorHint -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hint color via android:textColorHint"
android:textColorHint="#008800"
android:textSize="18sp" />
</LinearLayout>
ich die folgende Art definiert haben:
<!-- Text Appearance -->
<style name="TextAppearance.EditText" parent="">
<item name="android:textColor">#880000</item> <!-- this color is ignored -->
<item name="android:textColorHint">#008800</item> <!-- this color is ignored -->
<item name="android:textSize">18sp</item>
</style>
Ist das ein Fehler in Support-Bibliothek oder habe ich etwas verpasst?
Was die Überlegung dahinter ist? Was ist der Android: TextAppearance für dann? –
folgen Sie [this] (https://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/) Link und springen Sie zum Abschnitt Textdarstellung. Sie können sich ein Bild davon machen, wie Sie es richtig benutzen. :) –
Genau wie ich es benutze. Übrigens. Wenn Sie die Frage nicht gelesen haben, dreht es sich hauptsächlich darum, warum das Attribut textColor ignoriert wird. –