LinearLayout 线性布局有两种,分别是水平线性布局和垂直线性布局,LinearLayout属性中android:orientation为设置线性布局当其="vertical"时,为 垂直线性布局,当其="horizontal"时,为水平线性布局,不管是水平还是垂直线性布局一行(列)只能放置一个控件。

下面我们举例说明:

垂直线性布局

<?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" > <EditText
android:layout_width="100dp"
android:layout_height="wrap_content" /> <Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Button1"/> <Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="button2"/> </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" > <EditText
android:layout_width="100dp"
android:layout_height="wrap_content"
/> <Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Button1"/> <Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="button2"/> </LinearLayout>

运行结果:

android布局之线性布局的更多相关文章

  1. Android 自学之线性布局 LinearLayout

    线性布局(LinearLayout),线性布局有点想AWT编程里面的FolwLayout,他们都会将容器里面的组件挨个的排列起来. 他们最大的区别在于:Android的线性布局不会换行:AWT里面的F ...

  2. android 59 LinearLayout 线性布局

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

  3. Android开发之线性布局详解(布局权重)

    布局权重 线性布局支持给个别的子视图设定权重,通过android:layout_weight属性.就一个视图在屏幕上占多大的空间而言,这个属性给其设 定了一个重要的值.一个大的权重值,允许它扩大到填充 ...

  4. android学习之线性布局

    效图如下 移通152余继彪 该布局使用了线性布局完成 父布局为线性布局,黄色和灰色部分为水平的线性布局,剩余50%部分为水平线性布局,该布局中包含了两个垂直的线性布局分别占了三分之1和三分之二

  5. 第21/22讲 UI_布局 之 线性布局

    第21/22讲 UI_布局 之 线性布局 布局管理就是组件在activity中呈现方式,包括组件的大小,间距和对齐方式等. Android提供了两种布局的实现方式: 1.在xml配置文件中声明:这种方 ...

  6. Android:控件布局(线性布局)LinearLayout

    LinearLayout是线性布局控件:要么横向排布,要么竖向排布 决定性属性:必须有的! android:orientation:vertical (垂直方向) .horizontal(水平方向) ...

  7. Android 布局(线性布局、相对布局)

    一.线性布局(LinearLayout) <LinearLayout****</LinearLayout>1. orientation(布局方向)value=0 horizontal ...

  8. Android——布局(线性布局linearLayout,表格布局TableLayout,帧布局FrameLayout)

    线性布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:androi ...

  9. Android -- UI布局管理,相对布局,线性布局,表格布局,绝对布局,帧布局

    1. 相对布局 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmln ...

随机推荐

  1. 按钮效果 css

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  2. Hibernate 使用说明

    Eclipse中hibernate连接mySQL数据库练习(采用的是hibernate中XML配置方式连接数据库,以后在更新其他方式的连接) Hibernate就是Java后台数据库持久层的框架,也是 ...

  3. 【python】由一个小例子看出python的灵活性,IF ELSE一例

    temp = input("请输入1到100之间的数字:") num = int(temp) if 1 <= num <= 100:                   ...

  4. Python: 设计模式 之 工厂模式例(2)(神奇的Python)

    #!/usr/bin/env python #coding=utf-8 # # 工厂模式第二例(神奇的Python) # 版权所有 2014 yao_yu (http://blog.csdn.net/ ...

  5. linux建立信任关系

    (1).切换到需要建立信任关系的用户(2).执行命令:ssh-keygen  -d,然后一直回车.该命令会在用户home目录下生成一个隐藏的.ssh目录.目录里面有两个文件:id_dsa.id_dsa ...

  6. 2016021902 - linux解压缩命令

    转载自:http://blog.csdn.net/luo86106/article/details/6946255 .gz 解压1:gunzip FileName.gz 解压2:gzip -d Fil ...

  7. LINQ小记

     //LINQ 根据长度查询出来            string[] strs = new string[] { "1", "22", "333& ...

  8. [转]DOS命令

    windows dos命令 - 知识天地 - 博客园http://www.cnblogs.com/mfryf/archive/2012/02/13/2348685.html

  9. 树莓派学习路程No.1 GPIO功能初识 wiringPi安装

    WiringPi是应用于树莓派平台的GPIO控制库函数,WiringPi遵守GUN Lv3.wiringPi使用C或者C++开发并且可以被其他语言包转,例如python.ruby或者PHP等.Wiri ...

  10. 在keil中使用Astyle格式化你的代码的方法

    一个好的程序,不仅要有好的算法,同时也需要有良好的书写风格.写出好的算法不容易,但是好的代码风格却并不困难.提到格式化代码,Astyle是一个不能错过的工具,它可以方便的将程序代码格式化成自己想要的样 ...