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:paddingLeft=”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)
TextView中,控制其以…结束
android:ellipsize=”end”

只有一行
android:singleLine=”true”

定义控件是否可见
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″
android:layout_alignWithParentIfMissing=”true”

仅在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″

android布局ui的更多相关文章

  1. Android开发 UI布局

    Android开发 UI布局一.线性布局LinearLayout 什么是线性布局? 其实呢,线性布局就是把所有的孩子摆在同一条线上 <?xml version="1.0" e ...

  2. Android 的UI基础布局的学习

    一. 今天学习了Android 的UI基础布局的部分,绝大多数的布局都在Androidstudio的这个界面里,如下: 在左边的框里的palette的内部,包含了的大多数的布局所要用的button按钮 ...

  3. 【转】在Android布局中使用include和merge标签

    内容转自:http://fengweipeng1208.blog.163.com/blog/static/21277318020138229754135/ 在我们开发android布局时,经常会有很多 ...

  4. Android成长日记-Android布局优化

    Android常用布局 1. LinearLayout(线性布局) 2. RelativeLayout(相对布局) 3. TableLayout(表格布局) 4. AbsoluteLayou(绝对布局 ...

  5. Android优化——UI检视利器:Hierarchy Viewer

    在Android的SDK工具包中,有很多十分有用的工具,可以帮助程序员开发和测试Android应用程序,大大提高其工作效率.其中的一款叫 Hierachy Viewer的可视化调试工具,可以很方便地在 ...

  6. android 布局之滑动探究 scrollTo 和 scrollBy 方法使用说明

    涉及到滑动,就涉及到VIEW,大家都知道,Android的UI界面都是由一个一个的View以及View的派生类组成,View作为基类,而常用的布局里面的各种布局就是它派生出来的ViewGroup的子类 ...

  7. android自定义UI模板图文详解

    不知道大家在实际开发中有没有自定义过UI模板?今天花时间研究了一下android中自定义UI模板,与大家分享一下. 每个设计良好的App都是自定义标题栏,在自定义标题栏的过程中大部分人可能都是自定义一 ...

  8. Android 高级UI设计笔记07:RecyclerView 的详解

    1. 使用RecyclerView       在 Android 应用程序中列表是一个非常重要的控件,适用场合非常多,如新闻列表.应用列表.消息列表等等,但是从Android 一出生到现在并没有非常 ...

  9. android 布局如何支持多种不同屏幕尺寸

    android 布局如何支持多种不同屏幕尺寸 --关于dp.layout-xxx.drawable-xxx作用的小结 转载自:http://blog.csdn.net/vincent_blog/art ...

随机推荐

  1. 获取网页上数据(图片、文字、视频)-b

    Demo地址:http://download.csdn.net/detail/u012881779/8831835 获取网页上所有图片.获取所有html.获取网页title.获取网页内容文字... . ...

  2. 1015: [JSOI2008]星球大战starwar - BZOJ

    Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝国的超级武器,并攻下了星系中几乎所有的星球.这些星球通过 ...

  3. [转载]jquery ajax/post/get 传参数给 mvc的action

    jquery ajax/post/get 传参数给 mvc的action 1.ActionResult Test1     2.View  Test1.aspx 3.ajax page 4.MetaO ...

  4. WPF MultiDataTrigger

    huhu <Style x:Key="Cell" TargetType="{x:Type Button}"> <Setter Property ...

  5. Android支付接入(三):电信爱游戏支付

    原地址:http://blog.csdn.net/simdanfeg/article/details/9011977 注意事项: 1.电信要求必须先启动电信的闪屏界面 2.非网络游戏不允许有Inter ...

  6. 初试docker以及搭建mysql on docker

    前一阵阅读了google的borg论文,在最后的related works和总结中发现了kubernetes.从论文中了解的kubernetes这个东西很有意思,按照论文所说,它的实现有希望解决an ...

  7. 【Visual C++】一些开发心得与调试技巧

    自己平时收集的一些技巧与心得,这里分享出来,普及一下知识. 1.如何在Release状态下进行调试 Project->Setting=>ProjectSetting对话框,选择Releas ...

  8. MSSQLServer基础03(数据检索(查询))

    执行备注中的代码创建测试数据表. 简单的数据检索 :SELECT * FROM Student 只检索需要的列 :SELECT sName FROM Student .ame FROM Student ...

  9. 配置SQL Server 2008服务器

    怎么配置SQL Server 2008服务器_百度经验 http://jingyan.baidu.com/article/9faa7231a922c1473c28cb23.html 1.验证安装是否成 ...

  10. ASP.NET树形控件TreeView的递归绑定

    来自:http://blog.csdn.net/xqf003/article/details/4958727