Thank you.
Can you please help me understand what is the difference between:
<test.MyButton android:id="@+id/my_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" style="@style/MyButton" />
with this:
<test.MyButton android:id="@+id/my_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
one is with 'style' attribute and one is without?
If I don't specified, where will android get the 'style' for my widget?
And how can I put the default style for my widget? i.e. It will use
'@style/MyButton' when i don't specify anything?
Thank you.
On Sun, Feb 15, 2009 at 9:14 AM, Meryl Silverburgh
<[email protected]> wrote:
> Thank you Bill,
>
> I get 'ERROR Error: No resource found that matches the given name:
> attr 'style' in android eclipse plugins.
>
> Thanks for any more pointers.
>
>
>
> On Sun, Feb 15, 2009 at 6:52 AM, Ben Williamson <[email protected]> wrote:
>>
>> 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
-~----------~----~----~----~------~----~------~--~---