Is there any reason why is textColor
property being ignored when it is set via custom textAppearance
style?
<style name="EditTextAppearance" parent="@android:style/TextAppearance.Widget.EditText">
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/blue</item> <!-- IGNORED -->
</style>
Setting style in XML:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/EditTextAppearance"
/>
For some reason, default theme control color is not overridden by this style.
The only way how I am able to set color is by setting textColor
property in EditText
(but this is not what I want):
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/EditTextAppearance"
android:textColor="@color/blue"
/>
Note, custom textAppearance
with textColor
created for TextView
works without problem.
I tried to replace EditText
by android.support.v7.widget.AppCompatEditText
or android.support.design.widget.TextInputEditText
but the result was the same. Still not working. So the problem is not in EditText
implementation.
I found question with the same problem Why is textColor in android:textAppearance ignored?. Unfortunately, without answer.
Somewhere along the line, the wrong/default value for textColor
is being picked up and applied. You can force the android:textColor
that you define in android:textAppearance
to be used by setting android:textColor="@null"
in your XML for EditText
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With