I have made style with following code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">150dip</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
And applied it as:
<EditText
style="CodeFont"
android:id="@+id/txt_username"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
but its not getting applied.
If i write same style in as:
<EditText
android:id="@+id/txt_username"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:ems="10"
android:inputType="textPersonName" />
Then it gets applied.
Is there anything wrong with my code?
The proper way to set the style is:
style="@style/CodeFont"
For more info check the docs
http://developer.android.com/guide/topics/ui/themes.html
Also check styles.xml
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/styles.xml
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