I am very new to Android Studio. As a beginner I have created a simple app just for testing purpose and to view the appearance of Android studio material theme. I am current
In res/values-v21/styles.xml,
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:colorAccent">@color/custom_theme_color</item>
<item name="android:colorPrimaryDark">@color/custom_theme_color</item>
<item name="android:colorPrimary">@color/custom_theme_color</item>
</style>
The above code is simple and working well. In Android studio, it could be able to change from default sky blue color to any other colors like pink or green!
Create 3 files under xml ie. res/xml such as checked.xml, unchecked.xml and custom_checkbox.xml
checked.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2px" android:color="#FF00FF" />
<size android:height="20dp" android:width="20dp"/>
</shape>
unchecked.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2px" android:color="#ffc0c0c0" />
<size android:height="20dp" android:width="20dp"/>
</shape>
custom_checkbox.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:drawable="@xml/checked" />
<item android:state_pressed="true"
android:drawable="@xml/checked" />
<item android:drawable="@xml/unchecked" />
</selector>
From above second method, it (customized file) also could be able to create any shapes and colors based on our requirements. Even we can be able to customize the style, shapes and themes for a widget by using 2nd method.
Above two methods are working fine for me!
Also in from v23 with AppCompat you can use android.support.v7.widget.AppCompatCheckBox and change CheckBox style like this:
<android.support.v7.widget.AppCompatCheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:theme="@style/CheckBox"
/>
where in style.xml:
<style name="CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox">
<item name="colorControlNormal">@color/checkbox_normal</item> <!-- border color -->
<item name="colorControlActivated">@color/checkbox_activated</item> <!-- fill color -->
<item name="colorControlHighlight">@color/checkbox_highlight</item> <!-- animation color -->
</style>