Meryl Silverburgh wrote:
> Hi,
>
> I am tying to define the style of MyWidget in my theme.
>
> I create a widget myself called 'MyWidget' and I want to define the
> style of MyWidget in my theme.
>
>
> And I have added this in my manifest file:
>
>   <application android:label="@string/app_name" 
> android:theme="@style/MyTheme">
>
> This in my themes.xml file:
> <resources>
>    <style name="MyTheme">
>     <item name="buttonStyleMyWidget">@style/MyWidget</item>
>     </style>
> </resources>
>
> and this in my styles.xml file:
>
> <?xml version="1.0" encoding="utf-8"?>
> <resources>
>       <style name="MyWidget">
>         <item name="android:background">@drawable/btn_mywidget_bg</item>
> </style>
> </resources>
>
> But android did not pick up the style of 'MyWidget' unless I
> specifically put 'style='@style/MyWidget'
>
> In other words, in my main.xml, if i specified my 'style' attribute,
> my background
> drawable was displayed correctly.
>   <test.MyWidget android:id="@+id/mywidget" style="@style/MyWidget" />
>
> but if I just do this:
> <test.MyWidget android:id="@+id/mywidget" />  , the background drawable
> is not display correctly.
>
> Can you please tell me what am I missing?
>
> Thank you.
>
> >
>    
Hey I'm still new as well but I think I see your issue....

If I'm not mistaken this should be changed...

<resources>
   <style name="MyTheme">
    <item name="buttonStyleMyWidget">@style/MyWidget</item>
    </style>
</resources>


TO

<resources>
   <style name="MyTheme">
    <item name="style">@style/MyWidget</item>
    </style>
</resources>


In all my testing the item name attribute needs to be what would normally be 
set inside your layout. Give that a try and let me know if it works.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to