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>