随笔 - 299  文章 - 0  评论 - 0  阅读 - 6322 

Android线性布局管理器

 

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>
复制代码
复制代码

posted on   杨申龙  阅读(21)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示