android之EditText

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>


 


 

發佈了28 篇原創文章 · 獲贊 2 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章