ch05 Android布局

阅读更多

--------------------------------------------线性布局LineLayout----------------------------------

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/LinearLayout1"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

 

    <TextView

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:background="#ff0000"

        android:text="@string/hello_world"

        tools:context=".MainActivity" />

 

    <LinearLayout

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:orientation="horizontal" >

 

        <TextView

            android:layout_width="fill_parent"

            android:layout_height="fill_parent"

            android:layout_weight="2"

            android:background="#00ff00"

            android:text="用户名:" />

 

        <TextView

            android:layout_width="fill_parent"

            android:layout_height="fill_parent"

            android:layout_weight="1"

            android:background="#0000ff"

            android:text="200" />

    LinearLayout>

 

LinearLayout>

--------------------------------------------框架布局FrameLayout-------------------------------

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/FrameLayout1"

    android:layout_width="match_parent"

    android:layout_height="match_parent" >

 

    <TextView

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:background="#ff0000"

        android:text="@string/hello_world"

        tools:context=".MainActivity" />

 

    <TextView

        android:layout_width="300dp"

        android:layout_height="300dp"

        android:layout_weight="1"

        android:background="#00ff00"

        android:text="100" />

 

    <TextView

        android:layout_width="150dp"

        android:layout_height="150dp"

        android:layout_weight="2"

        android:background="#0000ff"

        android:text="200" />

 

FrameLayout>

--------------------------------------------表格布局TableLayout--------------------------------

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/TableLayout1"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

 

    <TableRow

        android:layout_width="fill_parent"

        android:layout_height="wrap_content" >

 

        <TextView

            android:layout_width="fill_parent"

            android:layout_height="wrap_content"

            android:layout_weight="2"

            android:background="#ff0000"

            android:text="1000" />

 

        <TextView

            android:layout_width="fill_parent"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:background="#00ff00"

            android:text="2000" />

 

        <TextView

            android:layout_width="fill_parent"

            android:layout_height="wrap_content"

            android:layout_weight="2"

            android:background="#0000ff"

            android:text="3000" />

    TableRow>

 

    <TableRow

        android:layout_width="fill_parent"

        android:layout_height="wrap_content" >

 

        <TextView

            android:layout_width="fill_parent"

            android:layout_height="wrap_content"

            android:layout_weight="2"

            android:background="#0000ff"

            android:text="1000" />

 

        <TextView

            android:layout_width="fill_parent"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:background="#00ff00"

            android:text="2000" />

    TableRow>

 

TableLayout>

--------------------------------------------相对布局RelativeLayout-----------------------------

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/RelativeLayout1"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

 

    <TextView

        android:id="@+id/red"

        android:layout_width="150dp"

        android:layout_height="100dp"

        android:layout_centerInParent="true"

        android:background="#ff0000"

        android:gravity="center"

        android:text="@string/hello_world"

        tools:context=".MainActivity" />

 

    <TextView

        android:id="@+id/green"

        android:layout_width="150dp"

        android:layout_height="100dp"

        android:layout_above="@id/red"

        android:layout_alignBaseline="@id/red"

        android:layout_centerInParent="true"

        android:background="#00ff00"

        android:text="100" />

 

    <TextView

        android:id="@+id/blue"

        android:layout_width="50dp"

        android:layout_height="100dp"

        android:layout_above="@id/red"

        android:layout_toLeftOf="@id/green"

        android:background="#0000ff"

        android:text="200" />

 

RelativeLayout>

--------------------------------------------绝对布局AbsoluteLayout-----------------------------

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:id="@+id/AbsoluteLayout1"

    android:layout_width="match_parent"

    android:layout_height="match_parent" >

 

    <TextView

        android:id="@+id/red"

        android:layout_width="150dp"

        android:layout_height="100dp"

        android:layout_x="0dp"

        android:layout_y="100dp"

        android:background="#ff0000"

        android:gravity="center"

        android:text="@string/hello_world"

        tools:context=".MainActivity" />

 

    <TextView

        android:id="@+id/green"

        android:layout_width="150dp"

        android:layout_height="100dp"

        android:layout_x="0sp"

        android:layout_y="200sp"

        android:background="#00ff00"

        android:text="100" />

 

    <TextView

        android:id="@+id/blue"

        android:layout_width="50dp"

        android:layout_height="100dp"

        android:layout_x="0sp"

        android:layout_y="300sp"

        android:background="#0000ff"

        android:text="200" />

 

AbsoluteLayout>

线性布局LineLayout--------------------------------

ch05 Android布局_第1张图片

框架布局FrameLayout------------------------------

ch05 Android布局_第2张图片

表格布局TableLayout-------------------------------

ch05 Android布局_第3张图片

相对布局RelativeLayout----------------------------

ch05 Android布局_第4张图片

绝对布局AbsoluteLayout---------------------------

ch05 Android布局_第5张图片

 

  • 下周内容.pdf (2.3 MB)
  • 下载次数: 10
  • ch05 Android布局_第6张图片
  • 大小: 93.5 KB
  • ch05 Android布局_第7张图片
  • 大小: 94.3 KB
  • ch05 Android布局_第8张图片
  • 大小: 100.4 KB
  • ch05 Android布局_第9张图片
  • 大小: 96.2 KB
  • ch05 Android布局_第10张图片
  • 大小: 95.8 KB
  • com.ch05.rar (687.5 KB)
  • 下载次数: 8
  • szFemaleFriends.rar (825.3 KB)
  • 下载次数: 19
  • 注册_登录_我的资料.rar (563.1 KB)
  • 下载次数: 7
  • 查看图片附件

你可能感兴趣的:(Android,布局,线性布局,相对布局,表格布局)