zoukankan      html  css  js  c++  java
  • StateListDrawable

    可供设置的属性如下

    • drawable:引用的Drawable位图,我们可以把他放到最前面,就表示组件的正常状态~
    • state_focused:是否获得焦点
    • state_window_focused:是否获得窗口焦点
    • state_enabled:控件是否可用
    • state_checkable:控件可否被勾选,eg:checkbox
    • state_checked:控件是否被勾选
    • state_selected:控件是否被选择,针对有滚轮的情况
    • state_pressed:控件是否被按下
    • state_active:控件是否处于活动状态,eg:slidingTab
    • state_single:控件包含多个子控件时,确定是否只显示一个子控件
    • state_first:控件包含多个子控件时,确定第一个子控件是否处于显示状态
    • state_middle:控件包含多个子控件时,确定中间一个子控件是否处于显示状态
    • state_last:控件包含多个子控件时,确定最后一个子控件是否处于显示状态

    shape_btn_normal.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <solid android:color="#DD788A"/>
        <corners android:radius="5dp"/>
        <padding android:top="2dp" android:bottom="2dp"/>
    </shape>

    selctor_btn.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/shape_btn_pressed"/>
        <item android:drawable="@drawable/shape_btn_normal"/>
    </selector>

    然后按钮设置android:background="@drawable/selctor_btn"就可以了~ 你可以根据自己需求改成矩形或者椭圆,圆形等!

  • 相关阅读:
    qt忙等与非忙等
    获得文件路径 _pgmptr, _makepath, _splitpath
    RGB2YCbCr RGB2Gray
    qt Cannot connect creator comm socket /tmp/qt_temp.S26613/stub-socket: No such
    64位Ubuntu系统安装OpenCV 2.4.x+ffmpeg 完美解决方案
    vim按下ctrl+s僵死
    win32程序应用mfc库
    error LNK2005: _DllMain@12 已经在 dllmain.obj 中定义
    JavaScript中的浅拷贝和深拷贝
    Set和Map
  • 原文地址:https://www.cnblogs.com/loaderman/p/10169390.html
Copyright © 2011-2022 走看看