Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i find the definition of ?android:attr/dividerVertical?

I want to see the definition of divider vertical, I'm not sure exactly what the meaning of an attribute is but when click through to the definition of the attribute in intellij I'm taken to attrs.xml and shown the following, which does not help.

<!-- Drawable to use for generic vertical dividers. --> 
<attr name="dividerVertical" format="reference" />

My specific problem is I'm trying to achieve a list with an inset list divider with the dividerVertical style. In order to do this I have defined my own inset shape.

<inset xmlns:android="http://schemas.android.com/apk/res/android"
   android:insetLeft="30dip"
   android:insetRight="30dip">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <solid android:color="?android:attr/dividerVertical"/>
</shape>
</inset>

This does not work as android will not accept the "?android:attr/dividerVertical" as the colour. It would not work anyway as divider vertical has an alpha component, so what I need to know is what colour and opacity is divider vertical?? But ideally Id like to know how I can check the source of any resource components in android so that I never encounter this problem again.

Thanks

Piers

like image 295
PiersyP Avatar asked Dec 28 '13 16:12

PiersyP


People also ask

What attr in android?

The Attr interface represents an attribute in an Element object. Typically the allowable values for the attribute are defined in a schema associated with the document.

What is ATTR colorControlNormal?

attr/colorControlNormal The color applied to icons/controls in their normal state.


1 Answers

According to developer.android, ?[<package_name>:][<resource_type>/]<resource_name> is used for References To Theme Attributes.
So, for ?android:attr/dividerVertical, you can navigate to android-sdk\platforms\android-16\data\res\values. There, looking at attrs.xml, you can see

<!-- Drawable to use for generic vertical dividers. -->
<attr name="dividerVertical" format="reference" />

But this is just a "reference" for the theme. Looking at your target platform's themes.xml, you can find many lines for different themes something like

<item name="dividerVertical">@drawable/divider_vertical_dark</item>

The line you want is the line contained within the theme element for the theme you are using. It's easiest to copy the whole theme element to another text file and search there. Which brings up

<item name="dividerVertical">?android:attr/listDivider</item>

Searching again in the theme for "listDivider" you can find

<item name="listDivider">@drawable/list_divider_holo_dark</item>

So that is a drawable.

Searching for matching files you can find

./platforms/android-16/data/res/drawable-hdpi/list_divider_holo_dark.9.png
./platforms/android-16/data/res/drawable-mdpi/list_divider_holo_dark.9.png
./platforms/android-16/data/res/drawable-xhdpi/list_divider_holo_dark.9.png

These pngs happen to be 9 patches with the content consisting of a white square with an alpha value of 38.

like image 104
Nizam Avatar answered Sep 26 '22 15:09

Nizam