zoukankan      html  css  js  c++  java
  • android Button 颜色的变化(点击,放开,点击不放)

    参考:

    http://endual.iteye.com/blog/1534258

    总结:

    定义res/drawable/button_style.xml文件

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    	<item android:state_pressed="true" android:drawable="@drawable/play_press" />
    	<item android:state_focused="true" android:drawable="@drawable/play_press" />
    	<item android:drawable="@drawable/play" />
    </selector>
    

    以上需要放两种图片,play_press.png和play.png

    也可以直接使用颜色:

    <?xml version="1.0" encoding="utf-8"?>  
        <selector xmlns:android="http://schemas.android.com/apk/res/android">  
            <item android:state_pressed="true" android:drawable="@color/chocolate" />  
            <item android:state_focused="true" android:drawable="@color/darkslategray" />  
            <item android:drawable="@color/tan" />  
        </selector>  
    

      使用style文件

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    	android:orientation="vertical" android:layout_width="fill_parent"
    	android:layout_height="fill_parent">
    	<TextView android:layout_width="fill_parent"
    		android:layout_height="wrap_content" android:text="@string/hello" />
    	<Button android:id="@+id/button1"
    		android:layout_width="wrap_content" android:layout_height="wrap_content"
    		android:background="@drawable/button_style"
    		></Button>
    </LinearLayout>
    
  • 相关阅读:
    SQL随记(四)
    一些有用的方法命令
    导航目录
    HTML中&nbsp; &ensp; &emsp; &thinsp;等6种空白空格的区别
    MyBatis学习资料
    Spring Cloud资料
    聚类算法对比
    Spark 读取HBase数据
    ZooKeeper设置ACL权限控制
    大数据工具选择
  • 原文地址:https://www.cnblogs.com/sudawei/p/3412021.html
Copyright © 2011-2022 走看看