LinearLayout是线性布局控件:要么横向排布,要么竖向排布

决定性属性:必须有的!

android:orientation:vertical (垂直方向) 、horizontal(水平方向)

常用属性:

android:gravity------------设置的是控件自身上面的内容位置

android:layout_gravity-----设置控件本身相对于父控件的显示位置

android:layout_weight----- 给控件分配剩余空间


竖向排布实例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮1"
/> <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮2"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮3"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮4"
/>
</LinearLayout>

横向排布实例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" > <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮1"
/> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮2"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮3"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮4"
/>
</LinearLayout>

嵌套线性布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" > <LinearLayout >
..
</LinearLayout> <LinearLayout>
..
</LinearLayout> </LinearLayout>

Android LinearLayout线性布局的更多相关文章

  1. Android LinearLayout线性布局详解

    为了更好地管理Android应用的用户界面里的各组件,Android提供了布局管理器.通过使用布局管理器,Android应用图形用户界面具有良好的平台无关性.推荐使用布局管理器来管理组件的分布.大小, ...

  2. android 59 LinearLayout 线性布局

    ##常见的布局* LinearLayout 线性布局线性布局往左右拉是拉不动的,> 线性布局的朝向 vertical|horizontal> 线性布局的权重 weight 和 0dip一起 ...

  3. Android布局管理详解(1)—— LinearLayout 线性布局

    Android的布局方式共有6种,分别是LinearLayout(线性布局).TableLayout(表格布局).FrameLayout(帧布局).RelativeLayout(相对布局).GridL ...

  4. Android精通:View与ViewGroup,LinearLayout线性布局,RelativeLayout相对布局,ListView列表组件

    UI的描述 对于Android应用程序中,所有用户界面元素都是由View和ViewGroup对象构建的.View是绘制在屏幕上能与用户进行交互的一个对象.而对于ViewGroup来说,则是一个用于存放 ...

  5. Android零基础入门第25节:最简单最常用的LinearLayout线性布局

    原文:Android零基础入门第25节:最简单最常用的LinearLayout线性布局 良好的布局设计对于UI界面至关重要,在前面也简单介绍过,目前Android中的布局主要有6种,创建的布局文件默认 ...

  6. 2.2.1 LinearLayout(线性布局)

    本节引言 本节开始讲Android中的布局,Android中有六大布局,分别是: LinearLayout(线性布局), RelativeLayout(相对布局), TableLayout(表格布局) ...

  7. LinearLayout线性布局搭配权重属性的使用

    在开发中,我们是通过布局来完成应用界面的搭配的,通过各种布局,我们可以完成各种复杂的界面设计.而LinearLayout也就是我们说的线性布局,这个比较简单而且使用很广泛的一种布局.下面我们通过一个D ...

  8. LinearLayout线性布局

    作用 : 线性布局会将容器中的组件一个一个排列起来, LinearLayout可以控制组件横向或者纵向排列, 通过android:orientation属性控制; 不换行属性 : 线性布局中的组件不会 ...

  9. Android 使用线性布局LinearLayout和Button实现一个点红块游戏

    这个游戏的功能类似打地鼠. 项目地址:https://github.com/moonlightpoet/RedBlock 程序下载试玩地址:https://github.com/moonlightpo ...

随机推荐

  1. windows核心编程 DLL技术 【转】

    注:本文章转载于网络,源地址为:http://blog.csdn.net/ithzhang/article/details/7051558 本篇文章将介绍DLL显式链接的过程和模块基地址重定位及模块绑 ...

  2. linux中seq命令用法

    NAME seq - print a sequence of numbers SYNOPSIS seq [OPTION]... LAST seq [OPTION]... FIRST LAST seq ...

  3. 成功者的特点 VS 失败者的特点

  4. jmeter 压测工具

    Apache jmeter 压力测试 java 环境安装 https://www.cnblogs.com/smyhvae/p/3788534.html 下载地址和文档 http://itopic.or ...

  5. &lt;&lt;Python基础教程&gt;&gt;学习笔记 | 第04章 | 字典

    第04章:字典 当索引不好用时 Python唯一的内建的映射类型,无序,但都存储在一个特定的键中.键能够使字符.数字.或者是元祖. ------ 字典使用: 表征游戏棋盘的状态,每一个键都是由坐标值组 ...

  6. {}在javascript与(python,java)中的含义区别

    {}在javascript中是对象,其访问属性的方法为 a.name,a['name'],参见http://www.itxueyuan.org/view/6332.html {}在python,jav ...

  7. 管理voting disks

     管理voting disks 一.关于voting disk 的一些必需要知道的东西: 11g 曾经我们能够使用dd 命令来备份voting disk ,可是在11g 以后 oracle 不再支 ...

  8. SW线路中串联1K电阻的作用

    主要作用的去ESD,去干扰 和ADC上串的一样一样的作用 物美价廉的ESD方案 我还是觉得起到控制开关打开的快慢,也就是控制开关脉冲的上升沿,加了这个1K电阻,可以减缓上升延的斜率.如果上升沿过快,会 ...

  9. [读书笔记] learn python the hard way书中 有关powershell 的一些小问题

    ex46中,创建自己的python,  当你激活环境时 .\.venvs\lpthw\ Scripts\activate 会报一个错误 此时需要以管理员身份运行PowerShell,(当前的PS不用关 ...

  10. Android----SharedPreferences(存储数据)

    SharedPreferences详解 我们在开发软件的时候,常需要向用户提供软件参数设置功能,例如我们常用的微信,用户可以设置是否允许陌生人添加自己为好友.对于软件配置参数的保存,如果是在windo ...