通常、カスタム属性の例は次の形式です。
<declare-stylable name="MyView">
<attr name="name" format="string"/>
</declare-styleable>
とその使用法:
<com.example.test.MyView
customns:name="Hello"/>
したがって、カスタム ビューには、スタイル可能な属性と同じ名前が付けられます。
しかし、この例 (クリックすると完全なコードが表示されます) では、次のようになります。
<declare-styleable name="Options">
<attr name="titleText" format="string" localization="suggested" />
<attr name="valueColor" format="color" />
</declare-styleable>
によって使われた:
<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"
/>
ColorOptionsView
name で定義された属性にどのようにリンクされているのOptions
か疑問に思いました。