安卓发送邮箱界面 线形、表格、相对布局方式

线形布局

<?xml version="1.0" encoding="utf-8"?>
<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"

    tools:context="com.hanqi.lianxi.lianxiActivity1"

    android:orientation="vertical"
    android:gravity="center_horizontal"

    android:padding="16dp">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="收件人:"
        />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="标题:"
            />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="内容:"
            android:padding="@dimen/activity_vertical_margin"
            android:gravity="top"


            />
        </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="2"

        android:gravity="center_horizontal"

        >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="取消"
            android:layout_margin="20dp"

            />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="发送"
            android:layout_margin="20dp"
            />
    </LinearLayout>








</LinearLayout>

表格布局

<?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:stretchColumns="0,1"
    >

    <TableRow>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="收件人:"
            android:padding="@dimen/activity_horizontal_margin"
            android:layout_span="2"
            />

    </TableRow>

    <TableRow>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="标题:"
            android:padding="@dimen/activity_horizontal_margin"
            android:layout_span="2"
            />

    </TableRow>

    <TableRow
        android:layout_weight="4"
        >
        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="内容:"
            android:padding="@dimen/activity_horizontal_margin"
            android:layout_span="2"
            android:gravity="top"

            />

    </TableRow>

    <TableRow
        android:layout_weight="1">
        <Button
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_margin="20dp"

            android:text="取消"
            />

        <Button
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_margin="20dp"
            android:text="发送"
            />

    </TableRow>


</TableLayout>

相对布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentLeft="true"
        android:id="@+id/shoujian"
        android:padding="@dimen/activity_horizontal_margin"
        android:hint="收件人:"/>

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentLeft="true"
        android:hint="标题:"
        android:id="@+id/biaoti"
        android:layout_below="@+id/shoujian"
        android:padding="@dimen/activity_horizontal_margin"/>

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="330dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentLeft="true"
        android:hint="内容:"
        android:id="@+id/neirong"
        android:layout_below="@+id/biaoti"
        android:padding="@dimen/activity_horizontal_margin"
        android:layout_alignParentTop="true"

        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="取消"
        android:id="@+id/quxiao"
        android:layout_below="@+id/neirong"
        android:layout_margin="70dp"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="发送"
        android:layout_toRightOf="@+id/quxiao"
        android:layout_alignTop="@+id/quxiao"
        />

</RelativeLayout>
原文地址:https://www.cnblogs.com/fangchongyan/p/5321759.html