Styling all TextViews(or custom view) without adding the style attribute to every TextView

Viewed 8502

Is there a way to format all TextViews, Buttons or whatever with a theme ? Like in CSS when i want to format all a-tags

a{ /some css here/ }

I want to do that in android via xml when I'm applying a theme to my application. Any ideas ?Thanks

http://bartinger.at/

Update 1.0: I want to create a theme that formats the text in all TextViews green and in all EditTexts red. So that i just apply the theme and I never have to worry about the style attribute!

Update 1.1: So I found some that piece of code and I think that's a good beginning

<item name="android:textViewStyle">@style/MyTextView</item>
<item name="android:buttonStyle">@style/MyButton</item>

I think thats the answer to my question. But I have another one. I want to write my own ActionBar and wanted to know how I can apply a default style or default attributes (again without adding the style attribute in the layout xml :P )

I have a class

public class ActionBar extends LinearLayout{ }

and I'm gonna use it like that in my application

<at.bartinger.uil.ActionBar>....</at.bartinger.uil.ActionBar>

The ActionBar should have some default attributes (like height and width) and then adding some custom style attributes which could change from app to app (like background)

3 Answers
Related