0

I am trying to style my app and make own theme, but I faced with some problems, becouse I need some unusial behaviour.

I use Material Design theme with parent Theme.AppCompat.Light.DarkActionBar

Overview

Views has colors:

  • Text is textColorPrimary, textColorSecondary, textColorTertiary
  • Button is unknown gray color
  • Button text is textColorPrimary (?)
  • Checkbox and radiobutton unchecked border is textColorSecondary
  • Checkbox, radiobutton, sliders etc colors is colorAccent

But I need

  • Buttons have accentColor background and white text
  • All text (textColorPrimary, textColorSecondary, textColorTertiary) is a variants of dark green
  • Checkbox, radiobuttons should be primary color when checked and unchecked too.

My styles

Button

So, I create style Button.Default

<style name="Button.Default" parent="Widget.AppCompat.Button">
    <item name="colorButtonNormal">@color/colorAccent</item>
    <item name="android:textColor">@android:color/white</item>
</style>

and use It in my theme:

<item name="android:buttonStyle">@style/Button.Default</item>

OK, color changed, but background didn't. I add this line to the theme style:

<item name="colorButtonNormal">@color/colorFakeAccent</item>

OK

Checkbox

<style name="Checkbox.Default" parent="Widget.AppCompat.CompoundButton.CheckBox">
    <item name="android:textColor">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorPrimary</item>
</style>

And checkbox style didn't change. How can I set checkbox, radiobutton unchecked and checked color?

Community
  • 1
  • 1
Alexey Markov
  • 1,546
  • 2
  • 23
  • 41

3 Answers3

7

Use <item name="colorControlNormal"> <item name="colorControlActivated"> for change color of checkbox

Krutik
  • 732
  • 6
  • 19
0

Did you try to write your styles in the res/values-v21/styles.xml file?

frogatto
  • 28,539
  • 11
  • 83
  • 129
Sara
  • 1,844
  • 22
  • 18
0

you can Add your own style and images like so

<RadioButton
            android:id="@+id/my_rbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:button="@drawable/community_radiobutton_style" />

custom_radio_button.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_checked="true" android:drawable="@drawable/ic_radio_on" />
    <item android:state_checked="false" android:drawable="@drawable/ic_radio_off" />
</selector>
Mr T
  • 1,409
  • 1
  • 17
  • 24