Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

Android 基礎控制項:TextView 與 EditText

編輯:關於 Android 開發

Android 基礎控制項:TextView 與 EditText

TextView 用於顯示文字,EditText 則用於讓使用者輸入文字。兩者是 Android 介面開發中最常見的基礎控制項。

一般屬性

常用屬性包括 id、layout_width、layout_height、text、textSize、textColor 與 background。layout_width 與 layout_height 可設定為 wrap_content 或 match_parent,以決定控制項尺寸。

EditText 特殊屬性

hint 可顯示輸入提示;inputType 可指定輸入類型,例如文字、密碼、數字或電話號碼,藉此調整鍵盤與輸入行為。

範例

在 activity_main.xml 中建立 TextView 與 EditText,並於 MainActivity 透過 setContentView 載入版面配置。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved