I’m trying to create custom attributes to my button but I dont know which format I must use to images in attributes declaration…
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="TCButton">
<attr name="Text" format="string"/>
<attr name="BackgroundImage" format="android:drawable" />
</declare-styleable>
</resources>
Error is in the format=”android:drawable”…
You can use format=”integer”, the resource id of the drawable, and AttributeSet.getDrawable(…).
Here is an example.
Declare the attribute as integer in res/values/attrs.xml:
Set the attribute to a drawable id in your layout:
Get the drawable from the attribute in your custom widget component class:
To see all options possible check the android src here