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. MATLAB矩阵基础运算

    1.矩阵的加减运算X+Y或者X-Y:元素对应相加减.在此要求X与Y必须是同维矩阵,否则会出现错误信息.如果Y为一个数,则表示X中每一元素+Y或者-Y: %当X和Y都为同维矩阵时 X=[1,2,-3;2 ...

  2. DotnetBrowser高级教程-(4)使用MVC框架1-搭建基础框架

    我们这次重点介绍下MVC框架的使用. 如果您之前使用过微软的mvc web框架,那么dotnetbrowser的mvc框架相信您也会很快上手,两者之间相似度约有80%. 所谓的mvc,以一个例子为例: ...

  3. windows 网络编程[转]

    利用winsock编写网络应用程序服务端的步骤简述如下WSAStartup 初始化网络编程库 socket 创建套接字 bind 指定地址.端口,绑定套接字 listen 进入监听状态 accept ...

  4. 手动脱Mole Box壳实战总结

    作者:Fly2015 这个程序是吾爱破解脱壳练习第8期的加壳程序,该程序的壳是MoleBox V2.6.5壳,这些都是广告,能够直接无视了.前面的博客手动脱Mole Box V2.6.5壳实战中已经给 ...

  5. matlab-2

    function varargout = gmm(X, K_or_centroids) % ====================================================== ...

  6. Android微信分享功能实例+demo

    Android微信分享功能实例 1 微信开放平台注册 2 获得appId,添加到程序中,并运行程序 3 使用应用签名apk生成签名,添加到微信开放平台应用签名,完成注册 4 测试分享功能. 有问题请留 ...

  7. Allegro中解决鼠标放在走线上网络名、走线长度显示不出来的问题

    一些PCB设计者在使用allegro时,由于一些误操作 导致当鼠标放在走线(cline)和网络(net)上面时,软件没有显示该走线的所属网络,或者相关的长度信息.本人经过help文档发现,以下方法可以 ...

  8. Spark源码分析之六:Task调度(二)

    话说在<Spark源码分析之五:Task调度(一)>一文中,我们对Task调度分析到了DriverEndpoint的makeOffers()方法.这个方法针对接收到的ReviveOffer ...

  9. JavaScript读书笔记(6)-Function

    Function类型 ECMAScript中函数是对象,每个函数都是Function类型的实例,也有属性和方法,函数是对象,函数名实际上市一个指向函数对象的指针,不会与某个函数绑定: function ...

  10. Qt QImageReader 相似乎有bug

    Qt 版本号 5.4.1 (VS2010) 近期在做一个小程序,事实上非常easy,就是打开一个gif 动画.能够静态显示当中随意一帧图像.Qt 中有一个QImageReader 类.用这个类理论上说 ...