簡介
EditText控件繼承自TextView侣监,包含大部分TextView的屬性。它是一個可編輯的文本框菊霜,通常用來讓用戶輸入數(shù)據(jù)流部。
常用屬性
屬性 | 含義 |
---|---|
android:hint | 提示文本 |
android:lines | 設(shè)置固定行數(shù)用來決定EditText的高度 |
android:maxLines | 最大行數(shù) |
android:inputtype | 文本以何種形式顯示 |
android:scrollHorizontally | 超出寬度時,是否顯示橫拉條 |
android:capitalize | 設(shè)置首字母大寫 |
例如:將輸入的文本設(shè)置為密碼形式
<?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>