I need some help, I've been browsing for a while, but none of the topic I've found could resolve my problem. Hope you'll help me !
Here we go : I have a custom view, let's call it CustomView. It has some custom attributes too, defined in an attrs.xml file, like below :
<declare-styleable name="CustomView">
<attr name="customBackgroundColor" format="color"/>
<attr name="customTextColor" format="color"/>
<attr name="customWhatever" format="dimension"/>
</declare-styleable>
This view is part of a library I want to create so I can use it in multiple projects.
The funny part comes here : Actually, I'll use this view really often, so I want to define a style in styles.xml to define its property, so I don't have to go in every xml layout files where I use this view to edit its attributes. Something like this :
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="customViewStyle">@style/myCustomViewStyle</item>
</style>
<style name="myCustomViewStyle" parent="CustomViewStyle">
<item name="customBackgroundColor">@color/red</item>
<item name="customTextColor">@color/blue</item>
<item name="customWhatever">@dimen/someHeight</item>
</style>
So my question is : How do I define this "customViewStyle" key, and if it's possible, how to get informations from it ?
Bonus : I've been able to create this "customViewStyle" key by doing this :
<attr name="customViewStyle" format="reference"/>
But I haven't found yet how to exploit it.