2.27

一、今日继续布局管理器的xuexi

LinearLayout:线性布局管理器

1、特点:将放入其中的组件按照垂直或水平的方向进行排列


2、垂直线性布局管理器:

android:orientation="vertival"

每一行只能放置一个组件


3、水平线性布局管理器:

android:orientation="horizontal"

每一列只能放置一个组件


4、<LinearLayout>标记常用属性:

android:orientation:设置排列方式

android:gravity:设置显示位置


5、子组件属性

android:layout_weight属性:设置组件占父容器空间的比例,默认值为0.分配的是屏幕剩余空间

复制代码
复制代码
 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout
 3     xmlns:android="http://schemas.android.com/apk/res/android"
 4     xmlns:tools="http://schemas.android.com/tools"
 5     android:id="@+id/activity_main"
 6     android:layout_width="match_parent"
 7     android:layout_height="match_parent"
 8     android:paddingLeft="@dimen/activity_horizontal_margin"
 9     android:paddingRight="@dimen/activity_horizontal_margin"
10     android:paddingTop="@dimen/activity_vertical_margin"
11     android:paddingBottom="@dimen/activity_vertical_margin"
12     android:orientation="vertical"
13     tools:context="com.example.example.MainActivity">
14 
15     <EditText
16         android:layout_width="match_parent"
17         android:layout_height="wrap_content"
18         android:paddingBottom="20dp"
19         android:hint="QQ号/微信号/Email"
20         android:drawableLeft="@mipmap/zhanghao"
21         />
22 
23     <EditText
24         android:layout_width="match_parent"
25         android:layout_height="wrap_content"
26         android:paddingBottom="20dp"
27         android:hint="密码"
28         android:drawableLeft="@mipmap/mima"
29         />
30     <Button
31         android:layout_width="match_parent"
32         android:layout_height="wrap_content"
33         android:text="登录"
34         android:textColor="#FFFFFF"
35         android:background="#FF009688"/>
36 
37     <TextView
38         android:layout_width="wrap_content"
39         android:layout_height="wrap_content"
40         android:text="登陆遇到问题?"
41         android:layout_gravity="center_horizontal"
42         android:paddingTop="20dp"/>
43 
44 </LinearLayout>
复制代码
复制代码

二、遇到的问题

暂无

三、明日继续学习布局管理器

原文地址:https://www.cnblogs.com/zyljal/p/14905635.html