android-2

实验三UI线性布局管理器

  1. 实验名称

UI线性布局管理器

  1. 实验目的:

熟悉UI线性布局管理器

  1. 实验环境:

Windows xp+,jdk-6u32-windows-i586,adt-bundle-windows-x86-*。

  1. 实验结果:
  1. 主界面显示

 

                                       图 4-1-1 主界面显示

  1. 参考代码:

    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="@string/hello_world" />

   

    <LinearLayout

         android:id="@+id/lay1"

         android:layout_width="fill_parent"

         android:layout_height="wrap_content"

         android:orientation="vertical">

        

           <Button

             android:layout_width="fill_parent"

             android:layout_height="wrap_content"

             android:background="#ff0000"

            />

           <Button

             android:layout_width="fill_parent"

             android:layout_height="wrap_content"

             android:background="#ff0066"

            />

             <Button

             android:layout_width="fill_parent"

             android:layout_height="wrap_content"

             android:background="#33ff00"

            />

        

        

       

    </LinearLayout>

    <LinearLayout

         android:layout_width="wrap_content"

         android:layout_height="fill_parent"

         android:orientation="horizontal"

         android:layout_below="@id/lay1"

        >

        <Button

            android:layout_width="wrap_content"

            android:layout_height="fill_parent"

            android:background="#0033cc"

            android:layout_weight="1"

            />

        <Button

            android:layout_width="wrap_content"

            android:layout_height="fill_parent"

            android:background="#990000"

            android:layout_weight="1"

            />

         <Button

            android:layout_width="wrap_content"

            android:layout_height="fill_parent"

            android:background="#ff66cc"

            android:layout_weight="1"

            />

          <Button

            android:layout_width="wrap_content"

            android:layout_height="fill_parent"

            android:background="#993399"

            android:layout_weight="1"

            />

           <Button

            android:layout_width="wrap_content"

            android:layout_height="fill_parent"

            android:background="#666699"

            android:layout_weight="1"

            />

</LinearLayout>

  1. 实验总结:

    通过本次实验,我熟悉了UI线性布局管理器。学会了宽度,高度和背景颜色的设置。复杂的布局还需要进一步学习。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值