zoukankan      html  css  js  c++  java
  • android selector 无效的问题

    这几天做项目,用到背景选择器,无论怎么弄,都没有效果,找了很多资料都没有找到,样式是这样的

    <?xml version="1.0" encoding="UTF-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
       <item android:drawable="@drawable/title_new_normal"/>
        <item android:drawable="@drawable/title_new_selected" android:state_focused="true"/>
        <item android:drawable="@drawable/title_new_selected" android:state_selected="true"/>
        <item android:drawable="@drawable/title_new_selected" android:state_pressed="true"/>
        <item android:drawable="@drawable/title_new_selected" android:state_enabled="false"/>
        
    
    </selector>
    

    后来偶然间,把默认的放在最下面,就好用啦

    <?xml version="1.0" encoding="UTF-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    
        <item android:drawable="@drawable/title_new_selected" android:state_focused="true"/>
        <item android:drawable="@drawable/title_new_selected" android:state_selected="true"/>
        <item android:drawable="@drawable/title_new_selected" android:state_pressed="true"/>
        <item android:drawable="@drawable/title_new_selected" android:state_enabled="false"/>
        <item android:drawable="@drawable/title_new_normal"/>
    
    </selector>
    

     希望和我一样翻过类似错误的同仁,有个帮助

  • 相关阅读:
    Delphi中 StrToIntDef函数的用法:
    Delphi判断文件夹(目录)是否存在,不存在就创建一个,可以一次创建多级目录
    Delphi中Format的字符串格式化使用说明
    linux下可变参数打印
    c++11 thread
    QMessageBox 使用
    Ubuntu虚拟机配置nfs
    test
    Qt 布局时组建不贴边
    QPainter 居中写字
  • 原文地址:https://www.cnblogs.com/armyant/p/2424122.html
Copyright © 2011-2022 走看看