zoukankan      html  css  js  c++  java
  • android selector的item属性

    <selector>中item的属性问题:

    部分属性如下:

    android:state_pressed  :  true/false   //表示按下状态(例如按钮按下)
    android:state_focused  :  true/false   //表示聚焦状态(例如使用滚动球/D-pad聚焦Button)
    android:state_selected :  true/false   //表示选中状态(例如Tab 打开);
    android:state_checkable:  true/false   //表示可勾选状态(只对能切换可勾选—非可勾选的构件有用)
    android:state_checked  :  true/false   //表示勾选状态
    android:state_enabled  :  true/false   //表示可用状态
    android:window_focused :  true/false   //表示应用程序窗口有无焦点

    注意:selector中总是使用第一个匹配的item

    例:布局文件layout/activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent">     
        <EditText
            android:background="@drawable/bg_edittext"  //使用选择器
            android:textColorHint="#AAAAAA"
            android:hint="username"
            android:layout_width="match_parent"
            android:layout_height="40dp" />
    </LinearLayout>

    选择器文件drawable/bg_edittext.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <!-- 默认时的背景图片-->
        <item android:drawable="@drawable/pic1" />
        <!-- 没有焦点时的背景图片-->
        <item android:state_window_focused="false" android:drawable="@drawable/pic1" />
        <!-- 非触摸模式下获得焦点并单击时的背景图片-->
        <item android:state_focused="true" android:state_pressed="true"
            android:drawable="@drawable/pic2" />
        <!-- 触摸模式下单击时的背景图片-->
        <item android:state_focused="false" android:state_pressed="true"
            android:drawable="@drawable/pic3" />
        <!--选中时的图片背景-->
        <item android:state_selected="true" android:drawable="@drawable/pic4" />
        <!--获得焦点时的图片背景-->
        <item android:state_focused="true" android:drawable="@drawable/pic5" />
    </selector>
  • 相关阅读:
    android细节之禁用activity的系统的默认切换效果
    Spark1.0.0 属性配置
    Memory & MyISAM 引擎小注意! | OurMySQL
    memcached vs MySQL Memory engine table 速度比较_XMPP Jabber即时通讯开发实践_百度空间
    Mysql 官方Memcached 插件初步试用感受
    Aerospike | Aerospike Chinese
    MySQL内存表的特性与使用介绍 -- 简明现代魔法
    memory引擎的索引失效一例
    MySQL内存表(MEMORY)说明 | 一个PHP程序员的备忘录
    MySQL Memory 存储引擎浅析
  • 原文地址:https://www.cnblogs.com/mengfff/p/6764789.html
Copyright © 2011-2022 走看看