Having the custom view TestView
and declaring the following custom attribute:
<declare-styleable name="TestView">
<attr name="testAttr" format="reference"/>
</declare-styleable>
upon trying to open the resource selection dialog from the attribute overview in the visual editor of Android Studio, the dialog opens and only allows for string resources to be selected. How can the above be modified to show the same dialog that appears when selecting the background resource for a view?
Thanks in advance for your help! =)
EDIT------
I tried modifying the code to be:
<declare-styleable name="TestView">
<attr name="testAttr" format="reference|color" />
</declare-styleable>
as this is what I found android:background
to be, but the dialog to only select color resources opens instead.
If you want to create a new color you need to write this code at
colors.xml
, inside "values": (replace the hex number for the color you want)Then, once you create it, call it like that at
activity_main.xml
: (in the case you want to modify a textlayout)Hope this solves your problem :)