Android – change the default design theme to a custom color

I am new to Android studio. As a beginner, I have created a simple application for testing purposes only and see the appearance of Android studio material themes. I am currently using the latest version, i.e. l preview – studio version 0.8.2

Here, I just created textview, EditText, radio button and check box. When I select male or female, it displays sky blue. Can I change sky blue to green or yellow?

I don't know what the name is. You can see from the picture that EditText, radio buttons and check boxes are sky blue. When I try to click or select anything, those check boxes or radio buttons need to be changed from the default color to another color, such as green or yellow!

code

In RES / values / styles.xml,

<resources>
<!-- Base application theme. -->
<color name="custom_theme_color">#b0b0ff</color>
<style name="CustomTheme" parent="android:Theme.Material">
<item name="android:colorBackground">@color/custom_theme_color</item>
</style>
</resources>

In Android studio manifest.xml,

android:theme="@style/CustomTheme" >

Is there any other possibility to change from the default sky blue to green or yellow or purple?

Is there another way to change the default sky blue theme to another color, such as pink or green?

I want to learn, so please give me some suggestions on how to do this?

resolvent:

The first method:

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 works well. In the Android studio, it can be changed from the default sky blue to any other color, such as pink or green!

The second method:

Create three files under XML, namely. RES / XML, such as checked.xml, unchecked.xml and custom_ check@R_ 593_ 2419@.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_ check@R_ 593_ 2419@.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 the second method above, it (customization file) can also create any shape and color according to our requirements. Even we can use the second method to customize the style, shape and theme of widgets

The above two methods are good for me!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>