Updated 18 December 2016
In this blog,
We have shown you how to make a custom attribute and how to reference color attribute in drawable.
You can define attributes in the top <resources>
element or inside of an <declare-styleable>
element.
Note: All attributes share the same global namespace. That means that even if you create a new attribute inside of an
<declare-styleable>
element it can be used outside of it and you cannot create another attribute with the same name of a different type.
An <attr>
element has two XML attributes name
and format
. name
lets you call it something and this is how you end up referring to it in code, e.g.,R.attr.my_c_attribute
The format
attribute can have different values depending on the ‘type‘ of the attribute you want.
There are few simple steps,
Theme1
and Theme2
) define:Maybe this blog is helpable for you.
Source: https://github.com/android/
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
2 comments