android:orientation="vertical"表示该布局下的元素垂直排列;

在整体垂直排列的基础上想要实现内部水平排列,则在整体LinearLayout布局下再创建一个LinearLayout布局。

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"> <TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="合计"
android:textSize="20sp"
android:gravity="center"
/> <TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1619元"
android:textSize="20sp"
android:gravity="center"
android:layout_marginTop="23dp"
/> <LinearLayout
android:layout_width="fill_parent" //在这个LinearLayout下,不指定orientation就默认horizontal
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="总里程:"
/> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="266.86公里"
android:id="@+id/textView3"
/>
</LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="23dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="运费:"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="@color/colorAccent"
android:text="1639元"
/>
</LinearLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="23dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="起步价(含5公里):"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="1571元"
/>
</LinearLayout> </LinearLayout>

实现效果如下:

Android学习——LinearLayout布局实现居中、左对齐、右对齐的更多相关文章

  1. Android学习----五大布局

    1.LinearLayout 线性布局 android:orientation="horizontal" 制定线性布局的排列方式 水平 horizontal 垂直 vertical ...

  2. Python3基础 str ljust-rjust-center 左、右对齐 居中

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  3. Android学习5—布局简介

    Android界面的布局主要有四种,分别为RelativeLayout.LinearLayout.TableLayout.FrameLayout,接下来分别介绍这些布局如何使用(为了简单起见,接下来的 ...

  4. android 学习 之 布局(上)

    学习安卓布局前,先了解三个属性值: 1.fill_parent: 设置一个构件的布局为fill_parent将强制性地使构件扩展,以填充布局单元内尽可能多的空间 2.match_parent: And ...

  5. Android:LinearLayout布局中Layout_weight的深刻理解

    首先看一下LinearLayout布局中Layout_weight属性的作用:它是用来分配属于空间的一个属性,你可以设置他的权重.很多人不知道剩余空间是个什么概念,下面我先来说说剩余空间. 看下面代码 ...

  6. Word论文写作如何实现公式居中、编号右对齐

    第一步:插入表格 在公式所在行居中插入一行三列的表格,具体操作为: a.设置行居中,快捷键Ctrl+E: b.插入->表格->3×1的表格: 2 第二步:修改表格属性 新插入的表格三列等宽 ...

  7. android 学习 之 布局(下)LinearLayout,RelativeLayout,TableLayout,FrameLayout

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&q ...

  8. 15.Android中LinearLayout布局一些小记录

    在App中,我们经常看到布局中会有分割线,直接上代码: <?xml version="1.0" encoding="utf-8"?> <Lin ...

  9. android 学习Layout布局的使用

    android 常用布局 LinearLayout(线性布局) 线性的 垂直的 水平的RelativeLaytout(相对布局) 最灵活的TableLayout(表格布局) 使用GridView代替A ...

随机推荐

  1. Asp.Net Core部署到Linux服务器

    从2016年7月, .NET Core1.0 正式发布开始,由于时间问题,我没怎么关注过.NET Core,最近刚抽出点时间研究了下,先讲下如何把ASP.NET Core部署到Linux上吧.这里我用 ...

  2. Kattis -I Can Guess the Data Structure!

    I Can Guess the Data Structure! There is a bag-like data structure, supporting two operations: 1 x1  ...

  3. scrollBot滚动条美化,niceScroll有滚动条错位得问题

    http://www.htmleaf.com/Demo/201706204585.html

  4. Day 02 - 02 编程语言的分类

    编程语言的分类 机器语言分为: 1.机器语言 优点:执行代码效率非常快 缺点:开发效率低 2.汇编语言 优点(相对于机器语言):开发效率高 缺点(相对于机器语言):执行效率低 3.高级语言 解释型(同 ...

  5. BZOJ 4016 [FJOI2014]最短路径树问题 (贪心+点分治)

    题目大意:略 传送门 硬是把两个题拼到了一起= = $dijkstra$搜出单源最短路,然后$dfs$建树,如果$dis_{v}=dis_{u}+e.val$,说明这条边在最短路图内,然后像$NOIP ...

  6. 论文阅读《ActiveStereoNet:End-to-End Self-Supervised Learning for Active Stereo Systems》

    本文出自谷歌与普林斯顿大学研究人员之手并发表于计算机视觉顶会ECCV2018.本文首次提出了应用于主动双目立体视觉的深度学习解决方案,并引入了一种新的重构误差,采用自监督的方法来解决缺少ground ...

  7. Python学习笔记(4)列表

    2019-02-26 列表(list):①创建方法:用‘[ ]’,将数据包括起来,数据之间用逗号隔开.②空列表:empty = []③增删改查: 1)增加: a.append()方法——将元素添加到列 ...

  8. Python字典嵌套

    import copy menu = { "计算机科学与技术":{ "程序编程":{ "传统语言":{ "C++":&q ...

  9. Golang-and-package-version-managment

    参考文章 学习Golang之后对golang中的版本管理,包管理等机制一直没有很好的琢磨,偶然想起还是觉得很有必要进行归纳,包管理使用起来简单,无非就是install,uninstall,list等, ...

  10. 【henuacm2016级暑期训练-动态规划专题 B】Coloring Trees

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] f[i][j][k]前i个位置,第i个位置放j这个颜色,然后形成了k个联通块的最小花费 分第i个位置有没有已经放颜色两种情况考虑. ...