Usually al examples of custom attributes are of the form:
<declare-stylable name="MyView">
<attr name="name" format="string"/>
</declare-styleable>
and its usage:
<com.example.test.MyView
customns:name="Hello"/>
So the custom view has the same name as the stylable attributes.
But in this example (click for full code) you see:
<declare-styleable name="Options">
<attr name="titleText" format="string" localization="suggested" />
<attr name="valueColor" format="color" />
</declare-styleable>
used by:
<com.vogella.android.view.compoundview.ColorOptionsView
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
custom:titleText="Background color"
custom:valueColor="@android:color/holo_green_light"
/>
It made me wonder, how is it that ColorOptionsView
was linked to the attributes defined with name Options
?