Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

style not getting applied

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?

like image 864
C Sharper Avatar asked Dec 04 '22 09:12

C Sharper


1 Answers

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

like image 160
Raghunandan Avatar answered Jan 15 '23 14:01

Raghunandan