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. WebAPI中Message Handler与Filter的区别

    两者最主要的区别是关注点不同.Message Handlers应用到HTTP Request,Filters仅应用到controller/action上. 如果某种行为应用到大多数的Request时, ...

  2. Qt将表格table保存为excel(odbc方式)

    首先是保存excel的方法,可参照: http://dzmlmszp.blog.163.com/blog/static/179271962014819111812531/ ok,进入正题. 现在我有一 ...

  3. Arbitrage HDU

    Arbitrage                                              Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  4. Mysql学习(慕课学习笔记7)修改数据表(下)

    添加主键约束 ALTER TABLE tb1_name ADD [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,…….) ...

  5. debug模式启动provider

    debug 模式启动 1 sts中的配置见图片 2 centos中 ./knowledge-start.sh debug win系统ip ./knowledge-start.sh debug 192. ...

  6. NSString、NSData、char* 类型之间的转换-备

    1. NSString转化为UNICODE String: (NSString*)fname = @“Test”; char fnameStr[10]; memcpy(fnameStr, [fname ...

  7. Database JDBC Developer's Guide

    http://docs.oracle.com/database/121/JJDBC/datacc.htm#JJDBC28363

  8. man手册导出成txt,pdf,html的一些小技巧

    经常man一些shell命令,有时候有想导出来编辑或注释一下,所以要导出.方法有很多种,根据自己的实际需要觉得比较实用的记录下分享一下. 1.导出成txt man –t bash |col –b &g ...

  9. C语言---类型转换

    itoa 功 能:把一整数转换为字符串 用 法:char *itoa(int value, char *string, int radix); 详细解释:itoa是英文integer to array ...

  10. Linux下Bash运行脚本

    命令行应该这样写: sh -c "脚本字符串" example: sh -c "if ! type dpkg > /dev/null ; then echo 'so ...