1、概述
  布局管理器的用途:
  a、可以更好的管理组件;
  b、通过使用布局管理器,Android应用程序可以做到平台无关性

  布局管理器都是ViewGroup的子类,所有可充当容器的父类都是ViewGroup,而ViewGroup也是View的子类

  android学习日记12--布局管理器

  下面分别介绍常用的布局管理器

 

2、线性布局管理器
  LinearLayout,最常用的布局之一。它提供控件水平或垂直排列的模型

常用属性及其对应方法:

android学习日记12--布局管理器

gravity 可取属性说明:

android学习日记12--布局管理器

当需要为gravity设多个值时,可用|分隔开

布局XML:

 1 <?xml version="1.0" encoding="utf-8"?> 
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 3 android:orientation="horizontal" 
 4 android:layout_width="fill_parent" 
 5 android:layout_height="fill_parent" 
 6 android:id="@+id/lla" 
 7 android:gravity="right" 
 8 >  
 9  
10 <Button  
11 android:text="添加"  
12 android:id="@+id/Button01"  
13 android:layout_width="wrap_content"  
14 android:layout_height="wrap_content">   
15 </Button> 
16  
17 </LinearLayout> 
View Code

相关文章:

  • 2021-10-18
  • 2021-10-01
  • 2022-01-23
  • 2021-06-19
  • 2021-10-18
  • 2022-02-17
  • 2021-08-27
  • 2022-12-23
猜你喜欢
  • 2021-12-09
  • 2021-07-29
  • 2021-12-03
  • 2021-04-26
  • 2021-08-29
  • 2021-04-01
相关资源
相似解决方案