将默认设计主题更改为自定义颜色? [英] Change default design theme to customized color?

查看:255
本文介绍了将默认设计主题更改为自定义颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android studio的新手。作为一个初学者,我创建了一个简单的应用程序只是为测试目的和查看Android工作室材料主题的外观。我目前正在使用最新版本ie。

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 currently working with latest version ie. L preview - Studio 0.8.2 version.

在这里,我刚刚创建了textview,edittext,单选按钮和复选框。当我选择男性或女性,它看起来天蓝色。我可以改变天蓝色的绿色或黄色吗?

Here, I have just created textview, edittext, radio buttons and checkboxes. When I select male or female, it appears sky blue color. Could I be able to change sky blue color as a green or yellow color?

我不知道是什么名字。从图片可以看到edittext,单选按钮和复选框选择状态为天蓝色。当我尝试点击或选择任何东西,那么这些复选框或单选按钮需要从默认颜色更改为其他颜色,如绿色或黄色!

I do not know what is the name for that. From the picture can able to see edittext, radio buttons and checkboxes selected state as a sky blue color. When I try to click or select anything then those checkboxes or radio buttons need to change from default color to other colors like green or yellow!

在res / values / styles.xml中,

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>

在Android Studio Manifest.xml中,

In Android Studio Manifest.xml,

android:theme="@style/CustomTheme" >

任何人都可以说我 - 是否有其他可能从默认天蓝色变为绿色黄色或紫色?

Please can anyone say me - Is there any other possible to change from default sky blue color to green or yellow or purple??

有没有其他方法将默认天蓝色主题更改为其他颜色,如粉红色或绿色?

Is there any other way to change default sky blue color theme to other colors like pink or green?

我想学习,所以请给我一些建议 - 我该怎么办?如果我在这里问过什么错误,请原谅我!

I would like to learn so please give me some suggestion - How should I do this? If I have asked anything wrong here please forgive me!

推荐答案

第一种方法:



styles.xml,

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>

上面的代码很简单,运行良好。在Android studio中,它可以从默认天蓝色更改为任何其他颜色,如粉红色或绿色!

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!

在xml下创建3个文件。 res / xml(例如checked.xml,unchecked.xml和custom_checkbox.xml)

Create 3 files under xml ie. res/xml such as checked.xml, unchecked.xml and custom_checkbox.xml

check.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!

这篇关于将默认设计主题更改为自定义颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆