Say i have a valid custom view, named com.package.MyCustomView (MyCustomView extends LinearLayout or any View)
I can use this in a activity layout like this
<com.package.MyCustomView
android:id="@+id/myView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
But i would like to have something like this:
<com.package.MyCustomView
android:id="@+id/myView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
MyCustomView_attribute1="100"
MyCustomView_attribute2="fantastic"/>
I’m imagining that in case of valid android xml attributes like android:layout_width the associated value (match_parent, wrap_content) will be set on a specific attribute of the parent View object (by use reflection or whatever.. ). I also am aware of the existence of the namespace (that line: xmlns:android="http://schemas.android.com/apk/res/android")..
In any case I would like something of the same kind – custom xml attributes for my custom for my view…
Is this possible? If yes – how? please give some details
Declare a stylable resource and some custom attributed with it. Official android tutorial.