com.package.MyCustomViewという名前の有効なカスタム ビューがあるとします(MyCustomView は LinearLayout または任意のビューを拡張します)。
このようなアクティビティレイアウトでこれを使用できます
<com.package.MyCustomView
android:id="@+id/myView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
しかし、私はこのようなものが欲しいです:
<com.package.MyCustomView
android:id="@+id/myView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
MyCustomView_attribute1="100"
MyCustomView_attribute2="fantastic"/>
Android:layout_widthのような有効な Android xml 属性の場合、関連付けられvalue (match_parent, wrap_content)
ているものが親 View オブジェクトの特定の属性に設定されることを想像しています (リフレクションなどを使用して..)。名前空間の存在も認識しています (その行: xmlns:android="http://schemas.android.com/apk/res/android"
)..
いずれにせよ、同じ種類のものが欲しいです-ビューのカスタムのカスタムxml属性...
これは可能ですか?はいの場合 - どのように?詳細を教えてください