Styling all TextViews (or a custom view) without adding a style attribute for each TextView

Is there a way to format all text elements, buttons or something else with a theme? Like in CSS, when I want to format all tags

and {/ some css here /}

I want to do this in android via xml when I apply a theme to my application. Any ideas? thank

http://bartinger.at/

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

Update 1.1: So I found some of this code, and I think a good start

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

I think this is the answer to my question. But I have one more. I want to write my own ActionBar and would like to know how I can apply the default style or default attributes (again without adding the style attribute to the xml: P layout)

I have a class

public class ActionBar extends LinearLayout{ }

and I will use it in my application

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

The ActionBar should have some default attributes (e.g. height and width) and then add some custom style attributes that can change from application to application (e.g. background)

+5
source share
3 answers

Yes, you can apply the theme to the whole application, and then all your texts will have this style.

styles.xml CustomTheme

:

<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>
</style>

-    "android: textStyle =" myStyle " Mystyle

+2

.

+1

for abr action you should look here http://developer.android.com/guide/topics/ui/actionbar.html

especially below, he explains very well how to style a panel

0
source

All Articles