Covers all TextViews (or custom view) without adding the style attribute to each TextView


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

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


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)

yes you can you can apply a theme to the whole application and then all your textviews will have that style.

Inside the styles.xml file you have to define your CustomTheme

for example:

<style name="CustomTheme" parent="android:Theme.Light">
  <item name="android:windowBackground">@color/custom_theme_color</item>
  <item name="android:colorBackground">@color/custom_theme_color</item>

you add something like text "android:textStyle="myStyle" and specify the details in Mystyle