Android移动终端设计实验一+基本组件应用实验

Android移动终端设计实验一+基本组件应用实验


实验1:基本组件应用实验

 

 

 

一、     实验目的

本次实验的目的是让大家熟悉Android开发中的UI设计,包括了解和熟悉常用控件的使用、界面布局、ArrayAdapter和SimpleAdapter适配器的基本用法。

 

二、     实验环境

Windows7  Eclipse MARS.2  AVD虚拟机

三、实验内容及结果

题目1:四种界面布局

分别使用LinearLayout、RelativeLayout、TableLayout和AbsoluteLayout四种布局设计登录窗口,界面如下图所示。

题目代码:

LinearLayout 实现

MainActivity.java

<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="wrap_content"

    android:orientation="vertical">

<LinearLayout

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="horizontal">

    <TextView

        android:id="@+id/user"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

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

    <EditText

        android:id="@+id/username"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:hint="please input your username"/>

   

    </LinearLayout>

   

    <LinearLayout

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:orientation="horizontal">

    <TextView

        android:id="@+id/pass"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="密码:" />

    <EditText

        android:id="@+id/password"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:hint="please input your password"/>

   

    </LinearLayout>

    <Button android:id="@+id/login"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="login">

       

    </Button>

 

</LinearLayout>

 

RelativeLayout 实现

MainActivity.java

<RelativeLayout 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"

    >

 

    <TextView

        android:id="@+id/user"

        android:layout_alignParentLeft="true"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

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

    <EditText

        android:id="@+id/username"

        android:layout_toRightOf="@+id/user"

        android:layout_alignBaseline="@+id/user"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:hint="input username"

        ></EditText>

    <TextView

        android:id="@+id/pass"

        android:layout_below="@+id/user"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="密码:"

        ></TextView>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值