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>
    
  • 相关阅读:
    Redis简单梳理及集群配置
    PDF.js 详情解说
    基于SMS短信平台给手机发送短信
    linux装OpenOffice后传---中文乱码的解决
    NodeJs小试牛刀--聊天室搭建
    算法之路--最小代价生成树
    Linux系统上安装OpenOffice
    项目部署之工具使用心得
    H5 Handlebars的简单使用
    JavaWeb国际化
  • 原文地址:https://www.cnblogs.com/sudawei/p/3412021.html
Copyright © 2011-2022 走看看