zoukankan      html  css  js  c++  java
  • 颜色的组合使用

    首先在res目录下,新建文件夹color

    然后再color文件夹下创建xml文件,比如取名为color_group.xml

    内容为:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
    android:color="#ffff0000" /><!-- 按的状态 -->
    <item android:state_focused="true"
    android:color="#ff0000ff" /><!-- 被框选的状态 -->
    <item android:color="#8800ff00" />
    </selector>

    然后再res/values目录下新建colors.xml

    内容为:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <color name="RED">#F00</color>
    <color name="GREEN">#0F0</color>
    <color name="BLUE">#00F</color>
    <color name="BLACK">#000</color>
    <color name="WHITE">#FFF</color>
    <color name="GRAY">#888</color>

    </resources>

    然后main.xml中的内容为:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    android:textColor="@color/RED"
    android:background="@color/GREEN" />
    <TextView
    android:id="@+id/test_locale"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />
    <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="按钮1"
    android:textColor="@color/color_group" />
    <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="按钮2"
    android:textColor="@color/color_group" />

    </LinearLayout>

    可以看到button按钮中的textColor中的颜色名字为res下新建目录color的color_group.xml文件的文件名,原因是因为R.java的color类下可以看到已经定义了color_group

  • 相关阅读:
    3. What’s New in Spring Security 4.2 spring security 4.2的新功能
    2. Introduction介绍
    1. Getting Started入门
    32. CAS Authentication
    Java序列化
    hive优化--数据倾斜优化
    hive优化之——控制hive任务中的map数和reduce数
    maven中引入jstl
    redis位操作
    Windows单机安装hadoop
  • 原文地址:https://www.cnblogs.com/xingmeng/p/2425651.html
Copyright © 2011-2022 走看看