android Button 颜色的变化(点击,放开,点击不放)
2013-11-07 10:48
507 查看
参考:
http://endual.iteye.com/blog/1534258
总结:
定义res/drawable/button_style.xml文件
以上需要放两种图片,play_press.png和play.png
也可以直接使用颜色:
使用style文件
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>
相关文章推荐
- android Button 点击背景与文字颜色变化效果
- android imageButton 点击按钮前中后,按钮颜色的变化
- Android 字体颜色变化(点击)
- textview中点击效果实现,比如点击textview中实现图片和文字的颜色变化(类似于button)
- android用Selector实现Button三种状态下背景颜色的变化
- android一个LinearLayout中具有几个控件,想要使那几个控件在LinearLayout被点击时,有颜色变化
- android按钮被点击文字颜色变化效果
- Android 按钮被点击文字颜色变化效果
- Android问题集(二)——TextView在点击时显示不同颜色,Button点击效果
- Android 如何给Button上面的文字设置点击后变颜色
- 3个按钮选一个 颜色产生变化 android button
- 【android】关于点击button1后改变颜色且保持,再点击别的button后颜色改变,button1变回原色
- Android 如何给Button上面的文字设置点击后变颜色
- android按钮被点击文字颜色变化效果
- Android Button按钮点击变换字体颜色
- Android中的Button自定义点击效果之改变点击时按钮的颜色
- Android View的点击事件导致文字颜色变化的实现原理
- android imageButton 点击按钮前中后,按钮颜色的变化
- Android控件在点击、选择时背景变化(button、listview)
- android点击Button后,buttton的背景和颜色改变