Android基礎TOP3:Activity的線性,相對,幀和表格版面配置的概括

來源:互聯網
上載者:User

標籤:ica   padding   android   logs   text   out   version   linear   drawable   

線性布局 LinearLayout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"     tools:context="com.example.top3.MainActivity" >      <EditText         android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:hint="請輸入註冊使用者名稱"/>  <requestFocus />  <EditText         android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:hint="請輸入密碼"        />  <EditText      android:layout_width="fill_parent"      android:layout_height="wrap_content"      android:ems="5"      android:hint="請再次輸入密碼" >       </EditText>    <EditText         android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:hint="請輸入郵箱"/>    <Button        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_margin="10dip"        android:background="@drawable/btn_bg"        android:gravity="center"        android:hint="註冊" /></LinearLayout>

相對布局 RelativeLayout:

 1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout  3     xmlns:android="http://schemas.android.com/apk/res/android" 4     android:layout_width="match_parent" 5     android:layout_height="match_parent" 6     > 7      8 <EditText  9     android:id="@+id/e1"10     android:layout_width="fill_parent"11     android:layout_height="wrap_content"12     android:hint="請輸入使用者名稱"13     />14 <EditText15     android:id="@+id/e2" 16     android:layout_below="@id/e1"17   android:layout_width="fill_parent"18     android:layout_height="wrap_content"19    android:hint="請輸入使用者名稱"    />20 21 <Button 22     android:id="@+id/b2"23       android:layout_below="@id/e2"24       android:layout_alignRight="@id/e2"25     android:layout_width="wrap_content"26     android:layout_height="wrap_content"27     android:text="註冊"28     />29 <Button 30     android:id="@+id/b1"31       android:layout_below="@id/e2"32       android:layout_toLeftOf="@id/b2"33     android:layout_width="wrap_content"34     android:layout_height="wrap_content"35     android:text="登入"36     />37 38 </RelativeLayout>

 

幀布局FrameLyaout:

<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent" >    <TextView        android:id="@+id/t1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:background="#f00"        android:height="300dp"        android:width="300dp" />      <TextView          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:background="#0f0"          android:height="100dp"          android:width="150dp" />      <TextView          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:background="#00f"          android:height="50dp"          android:width="100dp" /></FrameLayout>

 

表格版面配置TableLayout:

<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <TableRow >    <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="name"        android:paddingLeft="20dp"        android:textSize="16dp"        />    <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="20dp"        android:textSize="16dp"        />       <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="20dp"        android:textSize="16dp"        /></TableRow><TableRow>   <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="15dp"        android:textSize="8dp"        />         <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="40dp"        android:textSize="8dp"        />         <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="40dp"        android:textSize="8dp"        /> </TableRow><TableRow>   <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="15dp"        android:textSize="8dp"        />         <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="40dp"        android:textSize="8dp"        />         <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="40dp"        android:textSize="8dp"        /> </TableRow><TableRow>   <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="15dp"        android:textSize="8dp"        />         <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="40dp"        android:textSize="8dp"        />         <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="40dp"        android:textSize="8dp"        /> </TableRow><TableRow>   <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="15dp"        android:textSize="8dp"        />         <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="40dp"        android:textSize="8dp"        />         <TextView         android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:text="achievement"        android:paddingLeft="40dp"        android:textSize="8dp"        /> </TableRow></TableLayout>

 

 

Android基礎TOP3:Activity的線性,相對,幀和表格版面配置的概括

聯繫我們

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