<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
> <!--只能有一个子控件,必须是edit-->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:id="@+id/tl_username"
android:layout_height="wrap_content"> <android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="用户名"
android:maxLength="25"
android:maxLines="1"
/> </android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:id="@+id/tl_password"
android:layout_height="wrap_content"> <android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="密码"
android:maxLength="25"
android:maxLines="1"
android:inputType="textPassword"
/> </android.support.design.widget.TextInputLayout> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"
android:layout_gravity="center_horizontal"
android:id="@+id/btnLogin"
/> </LinearLayout>
package com.xiaozhuyisheng.jinjiedemos.activity;

import android.support.design.widget.TextInputLayout;
import android.view.View; import com.xiaozhuyisheng.jinjiedemos.BaseActivity;
import com.xiaozhuyisheng.jinjiedemos.R; import butterknife.BindView; public class TextInputLayoutDemoActivity extends BaseActivity { @BindView(R.id.tl_password)
TextInputLayout tl_password; @Override
protected int initLayoutID() {
return R.layout.activity_text_input;
} @Override
protected void initLogic() { findViewById(R.id.btnLogin).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
tl_password.setError("密码错误");
}
});
}
}

TextInputLayout 用法的更多相关文章

  1. Android5.0之TextInputLayout、FloatingActionButton的使用

    TextInputLayout和FloatingActionButton都属于MD风格的控件,比起普通的EditText和Button.ImageButton,TextInputLayout和Floa ...

  2. 【Android - MD】之TextInputLayout的使用

    TextInputLayout是Android 5.0新特性--Material Design中的一个布局控件,主要用来嵌套EditText,实现数据输入时的一些效果,如: 当输入框获取焦点时,输入提 ...

  3. Android学习之Design Support Library中TextInputLayout的使用

    今天学习了一个Android Design Support Library 中的TextInputLayout控件,感觉还不错,较之以往的Editetxt,多了几分灵活性,使用也非常easy,故此给大 ...

  4. Android Material Design控件学习(三)——使用TextInputLayout实现酷市场登录效果

    前言 前两次,我们学习了 Android Material Design控件学习(一)--TabLayout的用法 Android Material Design控件学习(二)--Navigation ...

  5. Android Design Support Library(2)- TextInputLayout的使用

    原创文章,转载请注明 http://blog.csdn.net/leejizhou/article/details/50494634 这篇文章介绍下Android Design Support Lib ...

  6. 【Android - 控件】之MD - TextInputLayout的使用

    TextInputLayout是Android 5.0新特性——Material Design中的一个布局控件,主要用来嵌套EditText,实现数据输入时的一些效果,如: 当输入框获取焦点时,输入提 ...

  7. EditText 基本用法

    title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...

  8. jquery插件的用法之cookie 插件

    一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...

  9. Java中的Socket的用法

                                   Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...

随机推荐

  1. JavaScript 基本类型和引用类型

    前言 ECMAScript变量可能包含两种不同数据类型的值:基本类型值和引用类型值.基本类型值指的是简单的数据段,而引用类型值指那些可能由多个值构成的对象. 基本类型 Undefined.Null.B ...

  2. 深入学习CSS外边距margin(重叠效果,margin传递效果,margin:auto实现块级元素水平垂直居中效果)

    前言 margin是盒模型几个属性中一个非常特殊的属性.简单举几个例子:只有margin不显示当前元素背景,只有margin可以设置为负值,margin和宽高支持auto,以及margin具有非常奇怪 ...

  3. Dijkstra算法的C++实现

    Dijkstra算法是在图中寻找两顶点最短路径的算法.   下面以下图有向图为例,说明其基本思想. 上图为转化为邻接矩阵存储:     现在我要寻找1点到其他点的最短距离以及路径: a)1点到各点的距 ...

  4. spring和mybatis的整合开发(基于MapperFactoryBean的整合开发(方便简单不复杂))

    MapperFactoryBean是mybati-spring团队提供的一个用于根据mapper接口生成mapper对象的类. 在spring配置文件中可以配置以下参数: 1.mapperInterf ...

  5. webpack构建Vue工程

    先开始webpack基本构建   创建一个工程目录 vue-structure mkdir vue-structure && cd vue-structure   安装webpack ...

  6. nc工具使用

    0x00 功能说明: 功能强大的网络工具,在网络工具中有“瑞士军刀”美誉,其有Windows和Linux的版本.因为它短小精悍,功能实用,被设计为一个简单.可靠的网络工具,可通过TCP或UDP协议传输 ...

  7. rest_framework框架的认识

    它是基于Django的,帮助我们快速开发符合RESTful规范的接口框架. 一  路由 可以通过路由as_view()传参 根据请求方式的不同执行对应不同的方法 在routers模块下 封装了很多关于 ...

  8. Django模型层-多表操作

    多表操作 一.创建模型 实例:我们来假定下面这些概念,字段和关系 作者模型:一个作者有姓名和年龄. 作者详细模型:把作者的详情放到详情表,包含生日,手机号,家庭住址等信息.作者详情模型和作者模型之间是 ...

  9. 1、Flutter_初体验_创建第一个应用_AndroidStudio_windows

    1.前言 至于 Flutter 是啥,我就不在这啰嗦了,下面以 windows 为例,展示一下从安装 Flutter 到运行 APP 整个过程: 2.安装 Flutter 2.1.中文介绍文档:htt ...

  10. Android串口通信(Android Studio)

    gilhub上已有开源项目: https://github.com/cepr/android-serialport-api 可以直接使用