android - Using A Custom Attribute That Is In A Style With A View -



android - Using A Custom Attribute That Is In A Style With A View -

lets have custom attribute in few styles so:

<style name="theme1" parent="android:theme.holo"> <item name="textviewbackground">#000022</item> <item name="android:background">#000000</item> </style> <style name="theme2" parent="android:theme.holo"> <item name="textviewbackground">#aa2200</item> <item name="android:background">#000000</item> </style>

can reference in standard view textview? like:

<textview android:id="@+id/txtnumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@currenttheme.textviewbackground" android:text="number" />

you need define textview style, this:

<style name="theme1" parent="android:theme.holo"> <item name="android:textviewstyle">@style/textviewstyle1</item> <item name="android:background">#000000</item> </style> <style name="theme2" parent="android:theme.holo"> <item name="android:textviewstyle">@style/textviewstyle2</item> <item name="android:background">#000000</item> </style> <style name="textviewstyle1" parent="@android:style/widget.textview"> <item name="android:background">#000022</item> </style> <style name="textviewstyle2" parent="@android:style/widget.textview"> <item name="android:background">#aa2200</item> </style>

then won't need set android:background attribute on each textview in xml, apply textviews not specify different background.

android android-layout

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -