• 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基础TOP3:线性布局的特点,常用属性,及权重值,androidtop3

Android基础TOP3:线性布局的特点,常用属性,及权重值,androidtop3

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

网友通过本文主要向大家介绍了淘宝top3是什么意思,top3是什么意思,top3,aj1top3,aj top3等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

Android基础TOP3:线性布局的特点,常用属性,及权重值,androidtop3


线性布局是一种让视图水平或者垂直布排列的布局;

常用属性:

androuid:orientation :表示布局方向

  •  取值vertical表示垂直布局
  •  取值horizontal表示水平布局

android:gravity 表示视图对齐方式

  • 内容包括 TOP,bottom,left,right,center_vertical,center_horizontal,center
  • 可以使用“|”分割填写多个值

布局中的视图可以使用如下多个属性:

android:layout_gravity 表示单个视图的对齐方式

android:layout_weight 表示单个视图所在大小的比重

  • 当Layout_weight为0时候视图大小自身确定
  • 当layout_weight大于0时,视图在线性布局方向根据比重拉伸

代码演示:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:orientation="horizontal" >
 6     <Button 
 7         android:layout_width="200dp"
 8         android:layout_height="100dp"
 9         android:text="adaflkjn"
10         android:gravity="bottom|center_horizontal"/>
11 
12 </LinearLayout>

android:gravity:是决定控件内元素在某个位置

<Button 
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:text="adaflkjn"
        android:layout_gravity="center"/>

 

android:layout_gravity是本元素在父元素里面显示的位置

weight的应用

<EditText 
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_weight="1"
       android:hint="sdaf"/>
   <Button 
       android:layout_width="1dp"
       android:layout_height="wrap_content"
       android:layout_weight="0"
       android:text="klndgjl"
       />

 <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="0"
      android:text="weight为0"
      android:background="#FFF0F5"
      />
  <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="weight为1"
       android:layout_weight="1"
      android:background="#800080"
      />
   <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="weight为4"
       android:layout_weight="4"
      android:background="#4B0082"
      />

 

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

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

  • Android基础TOP3:线性布局的特点,常用属性,及权重值,androidtop3

相关文章

  • 2017-05-26Android GZIP压缩IO流,优化APP数据传输(一),androidapp
  • 2017-05-26高仿it之家新闻客户端源码,高仿it之家源码
  • 2017-05-26Android开发学习——应用安装过程,android开发
  • 2017-05-26Android,androidstudio
  • 2017-05-26Android应用:横竖屏切换总结,android切换总结
  • 2017-05-26RecyclerView再封装,RecyclerView封装
  • 2017-05-26Android动态加载Activity原理
  • 2017-05-26浅谈Windows下SVN在Android Studio中的配置和基本使用,svnandroid
  • 2017-05-26Android第五天--&gt;创建自定义控件,android第五天
  • 2017-05-26[Android]Android布局优化之&lt;include /&gt;,androidinclude

文章分类

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

最近更新的内容

    • Afinal,afinal框架
    • Android中使用Notification实现普通通知栏(Notification示例一),rest示例java实现
    • 硅谷新闻2--禁止viewpager预加载,2--viewpager
    • Volley源码解析
    • Android 自定义View高级特效,神奇的贝塞尔曲线
    • mysql查询语句分析 explain用法
    • Linux内核系列—10.操作系统开发之内核HelloWorld,linuxhelloworld
    • LVS 内核实现分析(1)
    • android 动画详解(二)
    • 存储链路问题导致的RAC异常

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

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