Indirect reference (alias) to custom xml attribute in android -



Indirect reference (alias) to custom xml attribute in android -

si have custom android view. has custom attribute:

<com.my.customview custom:attribute="value_1" android:layout_height="wrap_content" android:layout_width="wrap_content" />

custom:attribute flag, defined by:

<resources> <attr name="attribute"> <flag name="value_1" value="8"/> <flag name="value_2" value="9"/> </attr> <declare-styleable name="customview"> <attr name="lobby_orientation"/> </declare-styleable> </resources>

what i'd modify value per config. illustration should value_1 in portrait, , value_2 in landscape. i'd create file in values-port , and other file in values-land:

<resources> <what_to_write name="here">value_1</what_to_write> </resources>

and layout this:

<com.my.customview custom:attribute="@what_to_write/here" android:layout_height="wrap_content" android:layout_width="wrap_content" />

is approach feasible in android?

it seems (according http://developer.android.com/guide/topics/resources/providing-resources.html page), simple values (and layouts , drawables) can have aliases. way i've found set value styles, , style file can defined per configuration.

<resources> <style name="customviewstyle"> <item name="what_to_write">value_1</item> </style> </resources> <com.my.customview style="customviewstyle" android:layout_height="wrap_content" android:layout_width="wrap_content" />

android android-custom-view

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -