Android UI开发布局实例及有关代码



<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:gravity="bottom"
    android:orientation="vertical"
    tools:context=".MainActivity" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:background="#22000000"
        android:orientation="horizontal" >

        <EditText
            android:layout_width="0dp"
            android:layout_height="40dp"
            android:layout_weight="3"
            android:background="#fafafa"


        />

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="click"
            android:text="发送"
            android:background="#0f5fdf"
            android:textColor="@android:color/white"
            />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#22000000"
        android:gravity="center_horizontal"
        android:orientation="horizontal" >
        <GridLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_weight="1.5"
            android:columnCount="1" >
            <Button android:text="," />
            <Button android:text="?" />
            <Button android:text="!" />
            <Button android:text="符" />
        </GridLayout>
        <GridLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_weight="4.5"
            android:columnCount="3"
            android:orientation="horizontal" >
            <Button android:text="1" />
            <Button android:text="2" />
            <Button android:text="3" />
            <Button android:text="4" />
            <Button android:text="5" />
            <Button android:text="6" />
            <Button android:text="7" />
            <Button android:text="8" />
            <Button android:text="9" />
            <Button android:text="123" />
            <Button android:text="﹂ " />
            <Button android:text="中/英" />
        </GridLayout>
        <GridLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_weight="1.5"
            android:columnCount="1" >
            <Button android:text="清空" />
            <Button android:text="0" />
            <Button android:text="," />
            <Button android:text="换行" />
        </GridLayout>
    </LinearLayout>
</LinearLayout>
















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

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView2"
        android:layout_weight="1"
        android:background="#000000"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"

        />

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView4"
        android:layout_weight="1"
        android:background="#808A87"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"/>

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView3"
        android:layout_weight="1"
        android:background="#0d40d9"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"/>

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView"
        android:layout_weight="1"
        android:background="#00FF00"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"/>

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView5"
        android:layout_weight="1"
        android:background="#f1061a"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"/>
</LinearLayout>


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

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="To"
        android:textSize="14dp"
        android:id="@+id/editText3" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Subject"
        android:textSize="14dp"
        android:id="@+id/editText2" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="388dp"
        android:hint="Message"
        android:textSize="14dp"
        android:id="@+id/editText"
        android:layout_marginBottom="10dp"
        android:gravity="top"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Send"
        android:layout_gravity="right"/>
</LinearLayout>


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

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@mipmap/smile1"
        android:id="@+id/imageView2"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@mipmap/rabbit1"
        android:id="@+id/imageView4"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@id/imageView2"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@mipmap/rabbit2"
        android:id="@+id/imageView6"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/imageView2"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@mipmap/rabbit3"
        android:id="@+id/imageView10"
        android:layout_below="@+id/imageView2"
        android:layout_centerHorizontal="true"
        />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@mipmap/rabbit4"
        android:id="@+id/imageView3"
        android:layout_above="@+id/imageView2"
        android:layout_centerHorizontal="true"
        />
</RelativeLayout>

图3

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

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/button1"
            android:text="accout:"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="Input yout account"

            />

    </TableRow>


    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/button2"
            android:text="Password:"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint=""
            />
    </TableRow>


    <Button
        android:id="@+id/button3"
        android:text="Login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

</TableLayout>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值