omega
omega

Reputation: 43833

How to use custom parents in Android style.xml file?

In my android app I make use of styles in the style.xml. I have this one

<style name="EditText" parent="@android:style/Widget.EditText">
    <item name="android:gravity">center</item>
    <item name="android:textColor">#000000</item>
    <item name="android:layout_width">fill_parent</item> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:background">@drawable/bg_edit_text</item>
</style>

But now I have another one, and I want the parent to be the code above. If I try

parent="@android:style/EditText"

it says it can't be found. Does anyone know how it's done?

Thanks

Upvotes: 0

Views: 124

Answers (1)

singularhum
singularhum

Reputation: 5122

Your EditText style is a custom style so putting @android:style/ will not work. Based on the android documentation on style inheritance, you can directly specify the name

parent="EditText"

or specify it in the name attribute without using the parent attribute

name="EditText.YourNewStyleName

http://developer.android.com/guide/topics/ui/themes.html#Inheritance

Upvotes: 1

Related Questions