Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> Android開發 >> 關於android開發 >> Android開發簡單GUI基本組件介紹

Android開發簡單GUI基本組件介紹

編輯:關於android開發

  1.TextView :顯示文本的標簽。其xml布局文件中的代碼為:

  <?xml version="1.0" encoding="utf-8"?>
  <TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="Hello,my name is TextView,I am maily show some text."
  />

  其他的屬性還有:android:typeface,android:textStyle,android:textColor

  2.Button: 按鈕控件是TextView 的子類,xml 布局文件中的代碼為:

  <?xml version="1.0" encoding="utf-8"?>
  <Button xmlns:android="http://schemas.android.com/apk/res/android"
  android:text="Hello,my name Button,I am the subclass of TextView"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"/>

  3.ImageView 和ImageButton:分別是TextView 和TextButton 的類似物
  每個都有android:src屬性,指出圖片的位置。ImageView 的xml布局文件的例子如下:

  <?xml version="1.0" encoding="utf-8"?>
  <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/icon"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:adjustViewBounds="true"
  android:src="@drawable/ffffgggg"
  />

  4.EditText 也是TextView 的子類,另外的屬性為:android:autoText、android:capitalize、android:digits、android:singleLine等。
  其簡單xml 布局代碼為:

  <?xml version="1.0" encoding="utf-8"?>
  <EditText xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/field"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:text="You can type words here..."
  android:singleLine="false"
  />

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved