码迷,mamicode.com
首页 > 其他好文 > 详细

图像状态资源的介绍~~以button按钮为例

时间:2014-10-27 21:16:53      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:android   http   io   sp   文件   on   问题   cti   bs   

android sdk 提供的Button按钮默认样式显得比较单调,为解决这个问题android提供了另外一种方法,通过引用资源文件来定义按钮在不同的状态下的显示样式

状态资源文件位于drawable目录下的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/function_greenbutton_pressed" /> <!-- pressed -->
         
    <item android:state_focused="true"
          android:drawable="@drawable/function_greenbutton_pressed" /> <!-- focused -->
         
 
    <item android:drawable="@drawable/function_greenbutton_normal" /> <!-- default -->
</selector>

然后再在布局文件中通过android:background引用该资源即可

android:background">@drawable/button_select

图像状态资源的介绍~~以button按钮为例

标签:android   http   io   sp   文件   on   问题   cti   bs   

原文地址:http://www.cnblogs.com/jiefeiduan/p/4055040.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!