简介
EditText控件继承自TextView,包含大部分TextView的属性。它是一个可编辑的文本框,通常用来让用户输入数据。
常用属性
属性 | 含义 |
---|---|
android:hint | 提示文本 |
android:lines | 设置固定行数用来决定EditText的高度 |
android:maxLines | 最大行数 |
android:inputtype | 文本以何种形式显示 |
android:scrollHorizontally | 超出宽度时,是否显示横拉条 |
android:capitalize | 设置首字母大写 |
例如:将输入的文本设置为密码形式
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入姓名"
android:maxLines="2"
android:inputType="textPassword"/>
</LinearLayout>

网友评论