在布局文件activity_main.xml,在默认添加的垂直线性布局管理器 < LinearLayout>中添加两个嵌套的< LinearLayout>,然后设置第一个 < LinearLayout>的排列方式为水平排列,在其中添加4个水平并排的TextView组件,并分别设置TextView组件文本的对齐方式,设置第二个< LinearLayout>的排列方式为垂直排列,并在其中添加4个垂直排列的TextView组件。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"tools:context="com.example.shenfan.linearlayout.MainActivity"><LinearLayoutandroid:orientation="horizontal"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"><TextViewandroid:layout_width="wrap_content"android:layout_height="match_parent"android:text="红色"android:gravity="center"android:background="#aa0000"android:layout_weight="1"/><TextViewandroid:layout_width="wrap_content"android:layout_height="match_parent"android:text="蓝色"android:gravity="top|center"android:background="#0000aa"android:layout_weight="1"/><TextViewandroid:layout_width="wrap_content"android:layout_height="match_parent"android:text="黄色"android:gravity="bottom|center"android:background="#aaaa00"android:layout_weight="1"/><TextViewandroid:layout_width="wrap_content"android:layout_height="match_parent"android:text="绿色"android:gravity="fill_vertical"android:background="#00aa00"android:layout_weight="1"/></LinearLayout><LinearLayoutandroid:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight = "1"><TextViewandroid:layout_width="wrap_content"android:layout_height="match_parent"android:text="第一行"android:layout_weight="1"/><TextViewandroid:layout_width="wrap_content"android:layout_height="match_parent"android:text="第二行"android:layout_weight="1"/><TextViewandroid:layout_width="wrap_content"android:layout_height="match_parent"android:text="第三行"android:layout_weight="1"/><TextViewandroid:layout_width="wrap_content"android:layout_height="match_parent"android:text="第四行"android:layout_weight="1"/></LinearLayout>
</LinearLayout>

运行界面如下图:

使用线性布局管理器布局Android界面相关推荐

  1. java -- GUI程序设计之无布局管理器布局

    无布局管理器布局 要采用无布局管理器布局,首先要取消Swing默认的布局管理器,否则布局方法不会生效.其方法是调用容器的setLayout方法,并将布局管理器设置为null.取消默认的布局管理器之后, ...

  2. android 布局管理器,【Android开发】布局管理器-表格布局

    在XML布局文件中定义表格布局管理器的基本语法: 属性列表 > 需要添加的UI组件 多个TableRow TableLayout支持的XML属性: android:collapseColumns ...

  3. Android精讲--界面编程2(布局管理器)

    为什么需要布局管理器 为了更好地管理Android应用的用户界面里的各种组件,Android提供了布局管理器.通过使用布局管理器,Android应用的图形用户界面具有良好的平台无关性.通常来说,推荐使 ...

  4. 布局管理器的嵌套实现微信朋友圈界面

    布局管理器的嵌套实现微信朋友圈界面 布局管理器嵌套原则: 根布局管理器必须包含xmlns属性 在一个布局文件中,最多只能有一个根布局管理器,如果需要有多个还需要使用一个根布局管理器将他们括起来. 不能 ...

  5. 疯狂Android讲义(二)——第二部分:第1组UI组件(布局管理器)

    一.第1组UI组件:布局管理器 Android 的界面组件比较多,不利于掌握它们内在的关系.为了帮助读者更好地掌握Android界面组件的关系,本书将会把这些界面组件按照它们的关联分析,分为几组进行介 ...

  6. Android 布局管理器

    布局管理器:控制组件是如何摆放的. 5种常用的布局管理器: RelativeLayout,相对布局管理器 LineraLayout,线性 FrameLayout,帧 TableLayout,表格 Gr ...

  7. pyqt 控件焦点_PyQt5(2)——调整布局(布局管理器)第一个程序

    我们拖拽一个UI文件,转为PY文件后生成一个类Ui_MainWindow 此时,我们新建一个文件,用来控制业务逻辑(继承界面中的类),跟界面分开,这样我们就完成了界面和逻辑相分离(这段代码使用率基本1 ...

  8. re管理器Java_自定义布局管理器-FormLayout

    第二部分:自定义布局管理器 在java.awt包与javax.swing包下有许多现成的布局类,比如BorderLayout.FlowLayout,还有较为复杂的.用于精确定位的布局类GridBagL ...

  9. java的布局管理器_Java中提供了几种布局管理器

    近日,很多网友都在关注Java中提供了几种布局管理器这个话题,那么Java中提供了几种布局管理器具体情况是怎么样的呢?Java中提供了几种布局管理器的相关信息有哪些?下面的内容是小编为大家找到的关于J ...

最新文章

  1. [YTU]_2429( C语言习题 学生成绩输入和输出)
  2. quartz 报错:java.lang.classNotFoundException
  3. js代码收集(1)_隐藏div、table间隔样式设置
  4. Ubuntu下对双显卡的支持问题
  5. 2017年10月23日23:58:04
  6. c语言将数组变为空,求助~~ 如何把数组变成动态输入的?
  7. IA-32 Architecture: the function of segment regitster(CS DS SS ES)
  8. 树莓派pwm驱动好盈电调及伺服电机
  9. 使用xmodmap修改键盘映射
  10. 未能找到任何适合于指定的区域性或非特定区域性的资源。请确保在编译时已将“***Form.resources”正确嵌入或链接到程序集“***”。。。
  11. Atitit 项目文档规范化与必备文档与推荐文档列表
  12. JAVA 实验报告总结
  13. 组图:释放性感诱惑 内地超级豪放女星大盘点
  14. VBA教程初级(五):复杂数组
  15. 置换密码及其python实现
  16. 全网最全实战注册苹果开发者账号教程
  17. 解决Linux中Ubuntu16.04声音一直静音的方法
  18. java fifo lifo_栈方法 LIFO - 队方法 FIFO
  19. excel单元格下拉选项怎么设置_单元格下拉效果怎么实现?
  20. HTML5 页面制作工具

热门文章

  1. 小米EA70 2022 款 评测
  2. 艾灸除烟专用空气处理设备
  3. 类实例:个人银行综合实例
  4. ubuntu14.04如何安装英伟达显卡驱动
  5. 初次学习ligerui
  6. 电子元器件基础1---电阻
  7. 京东国际销售数据查询(京东国际行业/品牌数据分析)
  8. 时间的玫瑰--但斌股市投资经典语录
  9. 已经拍好的照片怎么添加水印
  10. 【收藏】CSAPP深入理解计算机系统三万字长文解析