2

I've got a custom View in a library for which I'd like to provide the ability to apply a style defined in style.xml to override both standard and custom attributes. The catch is that this library is distributed as a Jar so there I am unable to package "resources" within the library.

I know that the conventional wisdom on this subject is that this cannot be done with a Jar'd custom View, however I have recently seen techniques such as the one described here for adding support for custom attributes within a custom View packaged in a Jar. This technique appears to work as expected when used within layout.xml but when used within style.xml results in:

No resource found that matches the given name: attr 'some_attr_name'.

My question boils down to this: Is there a way to define a Styleable within attrs.xml that maps to a custom View defined in a Jar, OR skip the Styleable declaration in attrs.xml and directly define a style within style.xml which can be applied to both custom and default attributes of a custom View defined in a Jar.

I'd like to be able to do something like this in style.xml:

<style name="myStyle">
  <item name="android:layout_width">fill_parent</item>
  <item name="android:layout_height">fill_parent</item>
  <item name="custom:fooText">some text</item>
</style>
4

0 に答える 0