EditView是android的基本視圖之一,有以下常用的方法:
<?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" >
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="只能輸入num"
android:inputType="number"/> //設置輸入格式
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="只能輸入0123"
android:background="@null" //取消默認的邊框
android:digits="0123"/> //限定輸入內容
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="多行"
android:minLines="2" //設置多行
android:maxLines="5"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="有圖片哦"
android:drawableRight="@drawable/ic_launcher"/> //設置圖片
</LinearLayout>