2.EditText控制項學習

來源:互聯網
上載者:User

EditText控制項

 

1         設定EditText不聚焦的簡便方法,用兩個EdtiText控制項,然後第一個控制項的寬度和高度都設定為0dp即可。如下所示:

<EditText

      android:layout_width="0dp"

      android:layout_height="0dp"

/>

<EditText

      android:layout_width="fill_parent"

      android:layout_height="wrap_content"

    />

2         設定最大輸入的字元數為3

android:maxLength="3"

3         設定文字框為單行輸入,預設的可以換行。

android:singleLine="ture"

4         限制輸入資訊

android:inputType="number"

5         設定提示資訊

android:hint="請輸入資訊"

6         在EditText中顯示圖片

android:drawableLeft="@drawable/title"//可以進行其他設定。

7         設定EditText的圓角

在drawable-mdpi中建立一個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"/>

   <corners android:radius="7dip"/>

   </shape>

然後在main.xml中添加屬性

android:background="@drawable/shape"

運行效果:

 

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.