LinearLayout是安卓中的常见布局,即线性布局。(提示:在Andriod中要常用alt+/快捷键来补全代码

  其中有一个重要的属性android:orientation,它是表示线性布局的方向问题。

  常见的这种布局案例有,计算器界面布局,下面就粘上代码: 

 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"  //引用包
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"  //垂直方向
tools:context=".MainActivity"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"  //权重,在容器中的占比
android:orientation="vertical" >

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"  //文字显示方向
/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
android:text="7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="1"
/>
<Button
android:text="8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="1"
/>
<Button
android:text="9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Button
android:text="/"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
android:text="4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="1"
/>
<Button
android:text="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="1"
/>
<Button
android:text="6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Button
android:text="*"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
android:text="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="1"
/>
<Button
android:text="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="1"
/>
<Button
android:text="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Button
android:text="+"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
android:text="cl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="1"
/>
<Button
android:text="."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="1"
/>
<Button
android:text="="
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Button
android:text="-"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>

  效果图:如下

Andriod布局之LinearLayout的更多相关文章

  1. Android 布局之LinearLayout

    Android 布局之LinearLayout 1 LinearLayout简介 LinearLayout是线程布局.它包括2个方向(android:orientation):“水平”(horizon ...

  2. Android 线性布局(LinearLayout)相关官方文档 - 指南部分

    Android 线性布局(LinearLayout)相关官方文档 - 指南部分 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用 ...

  3. Android 线性布局(LinearLayout)相关官方文档 - 布局參数部分

    Android 线性布局(LinearLayout)相关官方文档 - 布局參数部分 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商 ...

  4. Android的学习第六章(布局一LinearLayout)

    今天我们来说一下Android五大布局-LinearLayout布局(线性布局) 含义:线性布局,顾名思义,指的是整个Android布局中的控件摆放方式是以线性的方式摆放的, 主要作用:主要对整个界面 ...

  5. 1.[WP Developer体验Andriod开发]之Andriod布局 VS WinPhone布局

    0.写在前面的话 近来被HTML+CSS的布局折腾的死去活来,眼巴巴的看着CSS3中的flex,grid等更便捷更高效的的布局方式无法在项目中应用,心里那叫一个窝火啊,去你妹的兼容性,,, 最近体验下 ...

  6. Android四种基本布局(LinearLayout \ RelativeLayout \ FrameLayout \ TableLayout)

    ------------------------------------------LinearLayout---------------------------------------------- ...

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

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

  8. Android 五大布局(LinearLayout、FrameLayout、AbsoulteLayout、RelativeLayout、TableLayout )

    前言          欢迎大家我分享和推荐好用的代码段~~ 声明          欢迎转载,但请保留文章原始出处:          CSDN:http://www.csdn.net        ...

  9. Android 布局之LinearLayout 子控件weight权重的作用详析(转)

    关于Android开发中的LinearLayout子控件权重android:layout_weigh参数的作用,网上关于其用法有两种截然相反说法: 说法一:值越大,重要性越高,所占用的空间越大: 说法 ...

随机推荐

  1. iptables 实现centos内网机器访问外网

    环境:一台带外网和内网的机器,另一台只有内网,默认不能上网.两台机器都是centos系统带外网机器的外网ip为 123.221.20.11, 内网ip为 192.168.15.100内网机器的内网ip ...

  2. AVD启动不了 ANDROID_SDK_HOME is defined but could not find *.ini

    报错提示______________________________________________________________________ Starting emulator for AVD ...

  3. 《第一行代码》学习笔记3-活动Activity(1)

    1.活动-一种可以包含用户界面的组件,用于和用户进行交互. <Button android:id="@+id/button_1" android:layout_width=& ...

  4. Private Members in JavaScript

    Private Members in JavaScript Douglas Crockford www.crockford.com JavaScript is the world's most mis ...

  5. 定义了重复的system.web.extensions/scripting/scriptResourceHandler怎么办

    今天移转系统,都配置好之后,系统报错说我的web服务下的web.config 定义了重复的 system.web.extensions/scripting/scriptResourceHandler ...

  6. 通过 sp_configure 进行 Database Mail 配置

    通过 sp_configure 进行 Database Mail 配置 直接执行步骤一. 如果报错,则先执行步骤二,再执行步骤一. 一. sp_configre ; GO RECONFIGURE; G ...

  7. C语言中的静态局部变量

    代码: 0x601070 0x7ffcf44243fc 0x60106c 0x60106c 0x60106c [hu@localhost test]$ cat test.cpp #include &l ...

  8. java基础知识再学习--HashMap与ConcurrentHashMap的区别

    引用:http://blog.csdn.net/xuefeng0707/article/details/40834595 从JDK1.2起,就有了HashMap,正如前一篇文章所说,HashMap不是 ...

  9. 慕课linux学习笔记(八)常用命令(5)

    解压缩命令 常用压缩格式 .zip .gz .bz2 .tar.gz .tar.bz2 zip [压缩文件名] [ 原文件 ] #压缩文件 -r [压缩文件名] [ 源目录] #压缩目录 -r [压缩 ...

  10. apache将请求转发到到tomcat应用

    映射: 1.开启apache中的proxy模块(proxy.conf,proxy.load,proxy_http.load) 2.配置apache配置文件,<VirtualHost *:80&g ...