• 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>
    
  • 相关阅读:
    XMPP核心协议客户端
    平安中国
    读写XML的API们
    IM只是可以用来玩的东西
    再骂自己一句
    淡定
    自己打造SAX和DOM Parser
    Nickel Instant Messeging System
    XMPP RFC阅读笔记(二)
    think in java 笔记
  • 原文地址:https://www.cnblogs.com/sudawei/p/3412021.html
Copyright © 2020-2023  润新知