18Lab02-android UI

安卓UI设计

一、线性布局

1.


<?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:id="@+id/activity_text1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context="cn.edu.bzu.a18lab02.text1Activity">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginBottom="@dimen/activity_horizontal_margin"
        android:background="#000000" />


    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginBottom="@dimen/activity_horizontal_margin"
        android:background="#666666" />


    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginBottom="@dimen/activity_horizontal_margin"
        android:background="#0000FF" />


    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginBottom="@dimen/activity_horizontal_margin"
        android:background="#00FF00" />


    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginBottom="@dimen/activity_horizontal_margin"
        android:background="#FF0000" />


</LinearLayout>

2.


<?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:id="@+id/activity_text1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context="cn.edu.bzu.a18lab02.text1Activity">


    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="To"
        android:layout_weight="1"
        android:textColorHint="#ffff00"
        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Subject"
        android:layout_weight="1"
        android:textColorHint="#ffff00"
        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="100"
        android:gravity="top"
        android:text="Message"
        android:textColorHint="#ffff00"


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

二、相对布局


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_text1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="cn.edu.bzu.a18lab02.text1Activity"
    >

    <ImageButton
        android:id="@+id/button1"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="@drawable/smile1"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

    <ImageButton
        android:id="@+id/button3"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="@drawable/rabbit1"
        android:layout_alignTop="@+id/button1"
        android:layout_toLeftOf="@+id/button1"
        android:layout_toStartOf="@+id/button1"
        android:layout_marginLeft="42dp"
        android:layout_marginEnd="42dp" />

    <ImageButton
        android:id="@+id/button2"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="@drawable/rabbit3"
        android:layout_above="@+id/button1"
        android:layout_alignLeft="@+id/button1"
        android:layout_alignStart="@+id/button1"
        android:layout_marginBottom="40dp" />

    <ImageButton
        android:id="@+id/button5"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="@drawable/rabbit4"
        android:layout_marginTop="37dp"
        android:layout_below="@+id/button1"
        android:layout_alignLeft="@+id/button1" />

    <ImageButton
        android:id="@+id/button4"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="@drawable/rabbit2"
        android:layout_alignTop="@+id/button1"
        android:layout_toRightOf="@+id/button1"
        android:layout_toEndOf="@+id/button1"
        android:layout_marginLeft="34dp"
        android:layout_marginStart="34dp" />


</RelativeLayout>


三、表格布局


<?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:baselineAligned="false">

<TableRow android:orientation="vertical">
    <TextView
        android:text="Account:"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_column="0"
        />
    <EditText
        android:text="Input your account"
        android:layout_column="1"
        android:shrinkColumns="0,2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
</TableRow>
<TableRow>
    <TextView
        android:text="Password:"
        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:layout_span="0"
        android:ems="10"
        android:id="@+id/editText" />
</TableRow>
<Button
    android:text="Login"/>
</TableLayout>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值