Android之EditText控制項

來源:互聯網
上載者:User

標籤:

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLength="4"       //限制我們的輸入字數

 android:singleLine="true"   //限制我們輸入框滿後是否換行,true表示不換行
 android:inputType="number"   //限制我們輸入資料類型,number只表示輸入數字

 android:hint="這裡只允許輸入數字"  //在輸入框中提示我們要輸入的資訊

 android:drawableLeft="@drawable/title"    //在文字框最左面顯示一張名為title的圖片,圖片事先複製到drawable裡面title.jpg

/>

 

改變輸入框的形狀

1、在drawable中建立一個shape.xml,放入下列代碼

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--填充顏色-->
<solid android:color="#FFFFFF"/>
<!--設定矩形的四個角為弧線-->
<!--android:radius 弧形的半徑-->
<corners android:radius="7dip"/>
</shape>

2、在main.xml<EditText 中加入

 android:background="@drawable/shape"

 

Android之EditText控制項

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.