Android基础之LinerarLayout布局

每天一个小目标,你会变得很强大。

先上只用LinerarLayout布局完成一个登陆界面,效果图以及蓝图奉上:

 

所有的布局以及控件都是景观的子类。

先来点取景功能类常用的属性:

属性

含义

机器人:背景

设置背景

机器人:点击

设置查看是否响应单击事件

机器人:可见

控制视图的可见性

机器人:可聚焦

控件查看是否可以焦点电子杂志

机器人:ID

视图设置标识符,可通过findViewById 方法获取

再来点的的ViewGroup中的常用属性(的ViewGroup中为视图的子类):

属性

含义

机器人:layout_height

指定该子组件的布局高度

机器人:layout_width

指定该子组件的布局宽度

 

详细代码如下:

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    android:orientation="vertical"
    tools:context=".MainActivity">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/textView"
            android:background="#fff"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="登录"/>
    </LinearLayout>
    <LinearLayout
        android:background="#fff"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >
        <EditText
            android:id="@+id/name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="手机号"/>
        <EditText
            android:id="@+id/password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="密码"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <Button
                android:id="@+id/signin"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#fff"
                android:text="注册"
                />

            <Button
                android:layout_marginLeft="200dp"
                android:id="@+id/login"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="登录"
                />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

代码中的按钮,TextView的的的,的的EditText上为常用的控件,这里只需照敲即可,我会在后续的教程中逐步为大家讲解。

到这里就完成啦,继续努力学习中,如有问题欢迎提问。奋斗小青年GO!....

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值