LinearLayout和RelativeLayout

共有属性: java代码中通过btn1关联次控件 android:id="@+id/btn1"

控件宽度

android:layout_width="80px"    //"80dip"或"80dp"

android:layout_width =“wrap_content”

android:layout_width =“match_parent”

控件高度

android:layout_height="80px"    //"80dip"或"80dp"

android:layout_height =“wrap_content”

android:layout_height =“match_parent”

控件排布

android:orientation="horizontal” android:orientation="vertical“

控件间距

android:layout_marginLeft="5dip"      //距离左边

android:layout_marginRight="5dip"      //距离右边

android:layout_marginTop="5dip"      //距离上面

android:layout_marginRight="5dip"      //距离下面

控件显示位置

android:gravity="center"    //left,right, top, bottom

android:gravity="center_horizontal"

android:layout_gravity是本元素对父元素的重力方向。

android:layout_gravity属性则设置控件本身相对于父控件的显示位置

android:gravity是本元素所有子元素的重力方向。

android:layout_gravity="center_vertical"

android:layout_gravity="left"

android:layout_gravity="left|bottom"

TextView中文本字体

android:text="@String/text1"    //在string.xml中定义text1的值

android:textSize="20sp"

android:textColor=”#ff123456”

android:textStyle="bold"    //普通(normal), 斜体(italic),粗斜体(bold_italic)

定义控件是否可见

android:visibility=”visible”     //可见

android:visibility=”invisible”  //不可见,但是在布局中占用的位置还在

android:visibility=”gone”   //不可见,完全从布局中消失

定义背景图片

android:background="@drawable/img_bg"    //img_bg为drawable下的一张图片

seekbar控件背景图片及最大值

android:progressDrawable="@drawable/seekbar_img"

android:thumb="@drawable/thumb"

android:max = "60"

仅在RelativeLayout中有效:

在父亲布局的相对位置

android:layout_alignParentLeft="true"     //在布局左边

android:layout_alignParentRight="true"    //在布局右边

android:layout_alignParentTop="true"     //在布局上面

android:layout_alignParentBottom="true "  //在布局的下面

在某个控件的相对位置

android:layout_toRightOf="@id/button1"  //在控件button1的右边,不仅仅是紧靠着

android:layout_toLeftOf="@id/button1"   //在控件button2的左边,不仅仅是紧靠着

android:layout_below="@id/button1 "     //在控件button1下面,不仅仅是正下方

android:layout_above=“@id/button1”   //在控件button1下面,不仅仅是正下方

定义和某控件对奇

android:layout_alignTop=”@id/button1”  //和控件button1上对齐

android:layout_alignBottom=”@id/button1”  //和控件button1下对齐

android:layout_alignLeft=”@id/button1”  //和控件button1左对齐

android:layout_alignRight=”@id/button1”  //和控件button2右对齐

android:layout_centerHorizontal="true"        //水平居中

android:layout_centerVertical="true"

android:layout_centerInParent="true"

仅在LinearLayout中有效

设置控件在一排或一列中所占比例值

android:layout_weight="1"

设置Listview获取焦点时图片显示,默认为橙色,想去掉换成无色图片即可

android:listSelector="@drawable/nocolor"

listview设置分割线

android:divider="#000"
android:dividerHeight="1px"

android:drawSelectOnTop="false" 用来设置listview上的背景颜色会不会挡住(覆盖)内容,false表示不覆盖

linearLayout 和 relativeLayout的属性区别的更多相关文章

  1. linearLayout 和 relativeLayout的属性区别(转)

    LinearLayout和RelativeLayout 共有属性:java代码中通过btn1关联次控件android:id="@+id/btn1" 控件宽度android:layo ...

  2. LinearLayout和RelativeLayout

    LinearLayout和RelativeLayout 共有属性:java代码中通过btn1关联次控件android:id="@+id/btn1" 控件宽度android:layo ...

  3. LinearLayout和RelativeLayout 区别

    LinearLayout和RelativeLayout转自:http://blog.csdn.net/w176236767/article/details/6605848共有属性:java代码中通过b ...

  4. android LinearLayout和RelativeLayout实现精确布局

    先明确几个概念的区别: padding margin:都是边距的含义,关键问题得明白是什么相对什么的边距padding:是控件的内容相对控件的边缘的边距. margin  :是控件边缘相对父空间的边距 ...

  5. 用android LinearLayout和RelativeLayout实现精确布局(转)

    先明确几个概念的区别: padding margin都是边距的含义,关键问题得明白是什么相对什么的边距. padding是控件的内容相对控件的边缘的边距. margin是控件边缘相对父控件的边距. a ...

  6. [转]用android LinearLayout和RelativeLayout实现精确布局

    先明确几个概念的区别: padding margin都是边距的含义,关键问题得明白是什么相对什么的边距. padding是控件的内容相对控件的边缘的边距. margin是控件边缘相对父控件的边距. a ...

  7. Android开发——LinearLayout和RelativeLayout的性能对比

    0. 前言 我们都知道新建一个Android项目自动生成的Xml布局文件的根节点默认是RelativeLayout,这不是IDE默认设置,而是由android-sdk\tools\templates\ ...

  8. Android LinearLayout的android:layout_weight属性

    本文主要介绍Android LinearLayout的android:layout_weight属性意义 android:layout_weight为大小权重,相当于在页面上显示的百分比,它的计算是根 ...

  9. apple-touch-icon-precomposed 和 apple-touch-icon属性区别

    苹果safari浏览器当中apple-touch-icon-precomposed 和 apple-touch-icon属性是有区别的,之前在网上查了下相关的资料和苹果的开发文档手册,对这两中属性区别 ...

随机推荐

  1. Using AntiForgeryToken make it better

    原文发布时间为:2011-09-01 -- 来源于本人的百度文章 [由搬家工具导入] http://weblogs.asp.net/srkirkland/archive/2010/04/14/guar ...

  2. 张孝祥JavaScript视频教程flash版

    原文发布时间为:2008-09-16 -- 来源于本人的百度文章 [由搬家工具导入] 之前论坛有人发过RM版的,容量差不多有10G.现在这个是flash版的,只有1.2G共七部分. 第一部分:http ...

  3. 时间戳/Date(1354116249000)/ 转换

    从C#的Datatime格式通过Json传到Js里面,时间会显示成时间戳/Date(1354116249000)/ ,js转化如下 function GetDateFormat(str) { retu ...

  4. poj 3693 Maximum repetition substring 重复次数最多的连续子串

    题目链接 题意 对于任意的字符串,定义它的 重复次数 为:它最多可被划分成的完全相同的子串个数.例如:ababab 的重复次数为3,ababa 的重复次数为1. 现给定一字符串,求它的一个子串,其重复 ...

  5. poj 2796 Feel Good dp || 单调栈

    题目链接 题意 对于一个长度为\(n\)的非负整数数列\(a_1,a_2,-,a_n\),求\(max_{1≤l≤r≤n}f(l,r)\), 其中 \[f(l,r)=min(a_l,a_{l+1},- ...

  6. 桶排序Bucket sort(转)

    补充说明三点 1,桶排序是稳定的 2,桶排序是常见排序里最快的一种,比快排还要快…大多数情况下 3,桶排序非常快,但是同时也非常耗空间,基本上是最耗空间的一种排序算法 我自己的理解哈,可能与网上说的有 ...

  7. idea 快速生成代码的快捷键

     psvm 加ab键   mian方法快速生成 sout 加tab键   输出打印快捷键  alt+insert      快速生成get  set 方法 itar 生成array for代码块 fo ...

  8. Codeforces Round #464 (Div. 2) A. Love Triangle[判断是否存在三角恋]

    A. Love Triangle time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  9. Apollo 分布式配置中心

    1.  介绍 Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境.不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限.流程治理等特性,适用于微服务配置 ...

  10. ACM信息汇总

    一.ACM算法总结及刷题参考 (摘自:http://www.cnblogs.com/flipped/p/5005693.html) 初期: 一.基本算法: (1)枚举. (poj1753,poj296 ...