• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >Android > Android中的LinearLayout布局,linearlayout垂直布局

Android中的LinearLayout布局,linearlayout垂直布局

作者:网友 字体:[增加 减小] 来源:互联网 时间:2017-05-26

网友通过本文主要向大家介绍了android linearlayout,android layout布局,android tablelayout,android layout,android framelayout等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

Android中的LinearLayout布局,linearlayout垂直布局


LinearLayout : 线性布局

        在一般情况下,当有很多控件需要在一个界面列出来时,我们就可以使用线性布局(LinearLayout)了,  线性布局是按照垂直方向(vertical)或水平方向(horizontal)的顺序依次排序子元素,每一个子元素都位于前一个元素之后,下面我们就简单的了解一下吧

        在XML布局文件中会遇到如下一些单位

         px:是屏幕的像素点   dp:一个基于density的抽象单位,屏幕的物理尺寸   sp:同dp相似,但会根据用户的字体大小进行缩放  

        XML代码如下:改变一下android:orientation="vertical"  垂直方向(vertical)

<?xml version="1.0" encoding="utf-8"?>
<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="com.example.administrator.adapter.MainActivity">
<TextView
android:text="第一个TextView"
android:background="#ef0808"
android:gravity="center"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="100dp" />
<TextView
android:text="第二个TextView"
android:gravity="center"
android:background="#31ef0b"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="100dp" />
<TextView
android:text="第三个TextView"
android:gravity="center"
android:textSize="18sp"
android:background="#ec07ca"
android:layout_width="match_parent"
android:layout_height="100dp" />
<TextView
android:text="第四个TextView"
android:gravity="center"
android:textSize="18sp"
android:background="#f5d105"
android:layout_width="match_parent"
android:layout_height="100dp" />
</LinearLayout>
      运行结果:每一个TextView都从上往下依次排列

 

      XML代码如下:改变一下android:orientation="horizontal"  水平方向(horizontal)

<?xml version="1.0" encoding="utf-8"?>
<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="horizontal"
tools:context="com.example.administrator.adapter.MainActivity">
<TextView
android:text="第一个TextView"
android:background="#ef0808"
android:gravity="center"
android:textSize="18sp"
android:layout_width="100dp"
android:layout_height="100dp" />
<TextView
android:text="第二个TextView"
android:gravity="center"
android:background="#31ef0b"
android:textSize="18sp"
android:layout_width="100dp"
android:layout_height="100dp" />
<TextView
android:text="第三个TextView"
android:gravity="center"
android:textSize="18sp"
android:background="#ec07ca"
android:layout_width="100dp"
android:layout_height="100dp" />
<TextView
android:text="第四个TextView"
android:gravity="center"
android:textSize="18sp"
android:background="#f5d105"
android:layout_width="100dp"
android:layout_height="100dp" />
</LinearLayout>

运行结果:每一个TextView都从左向右依次水平排列

这两种线性布局唯一的差别就是android:orientation的值不同

实验总结:这两种线性布局唯一的差别就是android:orientation的值不同, 通过本次实验对Android中的线性布局有了一个初步的了解


作者:bigboss位

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • Android中的LinearLayout布局,linearlayout垂直布局
  • 和我一起看API(一)你所不知道的LinearLayout补充,apilinearlayout
  • LinearLayout嵌套,linearlayout
  • Android SwipeRefreshLayout下拉刷新与上拉加载+滑动删除
  • 阅读《Android 从入门到精通》(29)——LinearLayout 等四类方法

相关文章

  • 2017-05-224.1.2 Activity初窥门径
  • 2017-05-223.7 AnsyncTask异步任务
  • 2017-05-26谷歌IAP:skusBundle array associated with key ITEM_ID_LIST cannot contain more than 20 items.,jsarraycontain
  • 2017-05-26[android] 数据的异步加载和图片保存,
  • 2017-05-262016年Android市场的8个大胆预测,2016年android
  • 2017-05-26Android新手入门2016(6)--客户端编程思想的初步思考和Android学习路线
  • 2017-05-26说说Android6.0动态申请权限的那些坑,android6.0动态权限
  • 2017-05-26android6.0 adbd深入分析(四)adbd usb线拔掉再连接的过程
  • 2017-05-26Android学习笔记(32):通知推送Notification浅析
  • 2017-05-26Android 反编译和混淆,android反编译混淆

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • NDK中使用pthread多线程中自己写的一个BUG,ndkpthread
    • 【微学堂】第22期| Nginx的性能优化
    • Picasso处理同一url,但资源变了的情况,picassourl
    • hellocharts-android-Android图表开源库的使用(一)
    • [android] 手机卫士设备管理权限锁屏,android锁屏
    • cocos的Director、Scence、Layer(一)---摘自于官方文档,cocosscence
    • linux设备驱动程序之时钟管理(1)----最初的印象
    • 【玖哥乱弹】Android初学路上会遇到的瓶颈
    • Android学习笔记-TextView(文本框)(一),android-textview
    • Android初级教程_获取Android控件的宽和高,初级教程android

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有