线性布局 菜鸟级别的我

第一次写博客,也是刚刚学到的安卓,说实话单词都做不到能完全背下来。
但是却感觉挺有意思,安卓,恩感觉用那个应用去写并不是特别的难。
让我感觉新手也可以拥有一个属于自己的设计。嘿嘿,我要开始说我第一次做的了,老师讲了讲,我们再做的。

恩,那个match说实话不明白啥意思,padding一系列的上下左右都表示离界面的距离,自己来设置。
学习的布局共分为六种,分别是相对布局、线性布局、表格布局、网格布局、帧布局、绝对布局。
还有Android在创建工程时默认为相对布局。
这两个例子是线性布局的。

<?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_task1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="16dp"
    android:paddingTop="16dp"
    android:paddingRight="16dp"
    android:paddingLeft="16dp"
    android:orientation="vertical"    

  线性布局为LinearLayout,有两种形式,一种是水平线性布局,另一种是垂直线性布局。
orientation属性取值就为 vertical 垂直和horizontal水平。现在需要的是垂直。

    tools:context="cn.edu.bzu.a41lab_1.task1Activity">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@color/colorAccent"     
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#f123"                    
        android:layout_marginTop="10dp"           
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#ff1234"
        android:layout_marginTop="10dp"
    />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#f0123456"
        android:layout_marginTop="10dp"
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#fff123"
        android:layout_marginTop="10dp"
        />
</LinearLayout>
自己做的,手机拍的,还不能大于2M
background为背景颜色,可自己设,marginTop为与上一个下边界的距离。
这一个题做了一点,还有问题。与上一个不同的是这一个有一个是按钮Button。
原谅我刚刚学习安卓,才学了只一点点,以后的每一个都会是进步。哈哈

<?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_task2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="0dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:paddingTop="5dp"
    android:orientation="vertical"
    tools:context="cn.edu.bzu.a41lab_1.task2Activity">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="To"
      />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Subject" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Message"
        android:layout_weight="1"
        android:id="@+id/textView4" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Send"
        android:layout_marginStart="295dp"
        android:layout_marginLeft="15dp"
        android:id="@+id/button2" />
</LinearLayout>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值