A
A
Alexander Sulimov2013-02-16 20:44:34
Android
Alexander Sulimov, 2013-02-16 20:44:34

Android styles and themes?

I decided to try working with styles and themes and immediately began.
created style (task, make all text green)

<style name="PrivatStyle" parent="android:style/Theme.DeviceDefault">
        <item name="android:textColor">#00FF00</item>
    </style>

specified theme in the manifest
android:theme="@style/PrivatStyle"
As a result,
in the TextView - the text is green
in the EditText and the Button - plain white
Although, as I understand it, such a theme assignment will make all textColor green.
What point did I miss?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
F
FanKiLL, 2013-02-17
@FanKiLL

The fact is that Button, EditText is a completely different element, which has its own styles. You overridden only the color of the TextView, it seems.
For buttons, you need to redefine android:buttonStyle
For checkboxes, android:checkboxStyle
etc ...

F
FanKiLL, 2013-02-17
@FanKiLL

Try it
<style name="CustomText" parent="@style/Text">        <item name="android:textSize">20sp</item>        <item name="android:textColor">#008</item>    </style>  
like that

A
Alexandr Sulimov, 2013-02-17
@AlexandrDP

So far this is an option.
Everything works except ExpandableListView.
Somehow through ... strange, all this is done.
Here's how you can understand why everything applies everywhere, namely to the ExpandableListView reaction 0, although the same TextView lies on the layout.

  <style name="PrivatStyle" parent="Theme.Sherlock">
      
        <item name="android:textColor">@color/default_text_color</item>
        <item name="android:textAppearance">@style/MyTextAppearance</item>
        <item name="android:buttonStyle">@style/MyButtonStyle</item>
        <item name="android:editTextStyle">@style/MyEditTextStyle</item>
        <item name="android:imageButtonStyle">@style/MyImageButtonStyle</item>
        <item name="android:textViewStyle">@style/MyTextViewStyle</item>
        <item name="android:expandableListViewStyle">@style/MyExpandableListViewStyle</item>
        <item name="android:listViewStyle">@style/MyListViewStyle</item>
        
  </style>

  <style name="MyTextAppearance" parent="@android:style/TextAppearance">
        <item name="android:textColor">@color/default_text_color</item>
  	</style>
  	
  <style name="MyButtonStyle" parent="@android:style/Widget.Button">
        <item name="android:textColor">@color/default_text_color</item>
  	</style>
    
  <style name="MyEditTextStyle" parent="@android:style/Widget.EditText">
        <item name="android:textColor">@color/default_text_color</item>
  	</style>

  <style name="MyExpandableListViewStyle" parent="@android:style/Widget.ExpandableListView">
        <item name="android:textColor">@color/default_text_color</item>
  </style>

  <style name="MyListViewStyle" parent="@android:style/Widget.ListView">
        <item name="android:textColor">@color/default_text_color</item>
  	</style>

  <style name="MyImageButtonStyle" parent="@android:style/Widget.ImageButton">
        <item name="android:textColor">@color/default_text_color</item>
  	</style>
  
  <style name="MyTextViewStyle" parent="@android:style/Widget.TextView">
        <item name="android:textColor">@color/default_text_color</item>
  	</style>

F
FanKiLL, 2013-03-07
@FanKiLL

Try again like this to change the color in all controls at once.

 <style name="PinkTheme" parent="android:style/Theme">
        <item name="android:textColorPrimary">#FF69B4</item>
    </style>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question