Android StateListDrawable资源的使用(文本的高亮显示)
1.介绍

2.xml文件属性介绍

3.实例演示
<1>新建drawable文件
app--->src---->main---->res---->drawable ,选中drawable文件夹,右击new--->drawable resource file

<2>源码
(1)主界面
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="用户名" />
<EditText
android:id="@+id/editText"
android:textColor="@drawable/text_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="请输入用户名"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码" />
<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:textColor="@drawable/text_color"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="请输入密码"
android:inputType="textPassword" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button"
android:background="@drawable/background_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:text="登录" />
<Button
android:id="@+id/button2"
android:background="@drawable/background_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:text="取消" />
</LinearLayout>
</LinearLayout>
(2)background_img.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/bgd_008"></item>
<item android:state_pressed="false" android:drawable="@drawable/bgd_009"></item>
</selector>
(3)text_color.xml文件
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:color = "#f44"></item>
<item android:state_focused="false"
android:color="#000000"></item>
</selector>
Android StateListDrawable资源的使用(文本的高亮显示)的更多相关文章
- 处女男学Android(七)---Android 应用资源之StateListDrawable
前言 本篇Blog将记录关于Android应用资源中最经常使用的一个Drawable资源--StateListDrawable,本来说应当继续写UI方面的内容,突然跳到应用资源这边,主要是由于之前写界 ...
- StateListDrawable 资源
StateListDrawable 用于组织多个 Drawable 对象.当使用 StateListDrawable 作为目标组件 的背景.前景图片时,StateListDrawable 对象所显示的 ...
- 使用(Drawable)资源——StateListDrawable资源
StateListDrawable用于组织多个Drawable对象.当使用StateListDrawable作为目标组件的背景.前景图片时,StateListDrawable对象所显示的Drawabl ...
- 34.Android之资源文件res里drawable学习
我们经常看到android工程资源文件res下drawable如ldpi.mdpi.hdpi.xhdpi.xxhdpi文件,今天我们学习了解下. (1)drawable-hdpi里面存放高分辨率的图片 ...
- Android控件_TextView(显示文本框控件)
一.TextView控件的常用属性 1.android:id——控件的id 2.android:layout_width——设置控件的宽度 wrap_content(包裹实际文本内容) fill ...
- android应用资源预编译,编译和打包全解析
我们知道,在一个APK文件中,除了有代码文件之外,还有很多资源文件.这些资源文件是通过Android资源打包工具aapt(Android Asset Package Tool)打包到APK文件里面的. ...
- Android应用资源
Java刚開始学习的人直接在Java源代码使用"hello" 和123 类型的字符串和整型.但时间长了就会忘记当初定义的原因,有经验的或许会定义字符串常量ResultSet.TYP ...
- Android xml资源文件中@、@android:type、@*、?、@+含义和区别
一.@代表引用资源 1.引用自定义资源.格式:@[package:]type/name android:text="@string/hello" 2.引用系统资源.格式:@andr ...
- android 学习资源总结
http://android-arsenal.com/free 国外的android分类资源网站 http://www.ibm.com/developerworks/cn/topics/ IB ...
随机推荐
- Hadoop介绍及集群搭建
简介 Hadoop 是 Apache 旗下的一个用 java 语言实现开源软件框架,是一个开发和运行处理大规模数据的软件平台.允许使用简单的编程模型在大量计算机集群上对大型数据集进行分布式处理.它的核 ...
- Dubbo管理中心部署
我们在开发时,需要知道注册中心都注册了哪些服务,以便我们开发和测试.我们可以通过部署一个管理中心来实现.其实管理中心就是一个web应用,部署到tomcat即可. 管理端的部署: 1,首先我们要编译源码 ...
- 【原创】0. MYSQL++的环境准备
1. 获取 Google MYSQL++,第一个就是,然后跟着要求进行下载. 2. 编译和安装 其实在作者的各种README文档里面已经写得很清楚了,现在对一些可能会出现问题的地方进行一下回顾. Wi ...
- CSS变量教程
今年三月,微软宣布 Edge 浏览器将支持 CSS 变量. 这个重要的 CSS 新功能,所有主要浏览器已经都支持了.本文全面介绍如何使用它,你会发现原生 CSS 从此变得异常强大. 一.变量的声明 声 ...
- Django-restframework25 Pagination(分页)
Django-restframework25 Pagination(分页) 2017年11月11日 15:14:36 敲代码的伪文青 阅读数:1021 标签: restful 更多 个人分类: res ...
- BBS后台发送邮件&修改文章
一:Django发送邮件 在setting中配置 # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST ...
- What is the AppData folder?
Applies to Windows 8.1, Windows RT 8.1 The AppData folder contains app settings, files, and data spe ...
- javascript总结4:javascript常见变量
1 javascript变量 定义:变量在计算机中,是用于存储信息的"容器". 2 使用方法: 2-1 定义变量: var n1; 2-2 变量赋值: var n2=23.45; ...
- 献上一款漂亮的手写PHP验证码
献上一款漂亮的PHP验证码,可以根据个人需求作调整,代码如下(审美观不同,欢迎吐槽): <?php /** * Author: xiongwei * Email: 695704253@qq.co ...
- 请教一个Jquery ligerui 框架的小问题
关闭子窗体时,要刷新父窗体,百度了很多像使用“window.opener.location.reload();”都不行,和easyui框架是有区别的 在子窗体里写Response.Write(&quo ...