android布局ui
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的更多相关文章
- Android开发 UI布局
Android开发 UI布局一.线性布局LinearLayout 什么是线性布局? 其实呢,线性布局就是把所有的孩子摆在同一条线上 <?xml version="1.0" e ...
- Android 的UI基础布局的学习
一. 今天学习了Android 的UI基础布局的部分,绝大多数的布局都在Androidstudio的这个界面里,如下: 在左边的框里的palette的内部,包含了的大多数的布局所要用的button按钮 ...
- 【转】在Android布局中使用include和merge标签
内容转自:http://fengweipeng1208.blog.163.com/blog/static/21277318020138229754135/ 在我们开发android布局时,经常会有很多 ...
- Android成长日记-Android布局优化
Android常用布局 1. LinearLayout(线性布局) 2. RelativeLayout(相对布局) 3. TableLayout(表格布局) 4. AbsoluteLayou(绝对布局 ...
- Android优化——UI检视利器:Hierarchy Viewer
在Android的SDK工具包中,有很多十分有用的工具,可以帮助程序员开发和测试Android应用程序,大大提高其工作效率.其中的一款叫 Hierachy Viewer的可视化调试工具,可以很方便地在 ...
- android 布局之滑动探究 scrollTo 和 scrollBy 方法使用说明
涉及到滑动,就涉及到VIEW,大家都知道,Android的UI界面都是由一个一个的View以及View的派生类组成,View作为基类,而常用的布局里面的各种布局就是它派生出来的ViewGroup的子类 ...
- android自定义UI模板图文详解
不知道大家在实际开发中有没有自定义过UI模板?今天花时间研究了一下android中自定义UI模板,与大家分享一下. 每个设计良好的App都是自定义标题栏,在自定义标题栏的过程中大部分人可能都是自定义一 ...
- Android 高级UI设计笔记07:RecyclerView 的详解
1. 使用RecyclerView 在 Android 应用程序中列表是一个非常重要的控件,适用场合非常多,如新闻列表.应用列表.消息列表等等,但是从Android 一出生到现在并没有非常 ...
- android 布局如何支持多种不同屏幕尺寸
android 布局如何支持多种不同屏幕尺寸 --关于dp.layout-xxx.drawable-xxx作用的小结 转载自:http://blog.csdn.net/vincent_blog/art ...
随机推荐
- 如何在Linux下重命名多个文件
在Linux中,当你想要改变一个文件名,使用mv命令就好了.然而mv不能使用通配符重命名多个文件.可以用sed.awk或者与xargs结合使用来处理多个文件的情况.然而,这些命令行即繁琐又不友好,并且 ...
- 理解UIEdgeInsets
供参考 iOS 的控件,只看到 UIButton 可以设置 Padding/Insets,即按钮上文字或图片与按钮边界的间隙. CSS 上叫做 Padding,在 iOS 中叫做 Insets,UIB ...
- s3c2440之cache
cache高速缓冲存储器注意与块设备页高速缓存进行区别,一个是硬件的实现一个是软件的实现,块设备页高速缓存. s3c2440/s3c2410里面主要有一个arm920t的核,但同时包含几个协处理器,协 ...
- Python系统调用——运行其他程序
转载:http://blog.csdn.net/ssihc0/article/details/7738527 在Python中可以方便地使用os模块运行其他的脚本或者程序,这样就可以在脚本中直接使用其 ...
- java接口与继承
class Grandparent { public Grandparent() { System.out.println("GrandParent Created."); } p ...
- asp.net web api 开发时应当注意的事项
Self referencing when returning chain of objects. This can be solved using a design pattern called t ...
- Linux环境变量的设置和查看方法
Linux环境变量的设置和查看方法 1. 显示环境变量HOME [root@AY1404171530212980a0Z ~]# echo $HOME /root 2. ...
- tomcat启动报错:Unsupported major.minor version 51.0
myeclipse中添加项目后,发现项目启动时报错:Unsupported major.minor version 51.0 因为tomcat使用的jdk版本不支持你项目的jdk版本,需要你在myec ...
- 2013流行Python项目汇总
2013流行Python项目汇总 转自:http://www.kankanews.com/ICkengine/archives/102963.shtml Python作为程序员的宠儿,越来越得到人们的 ...
- HDU4704+费马小定理
费马小定理题意:求s1+s2+s3+...+sn;si表示n划分i个数的n的划分的个数,如n=4,则s1=1,s2=3 利用隔板定理可知,就是求(2^n-1)%mod-----Y 现在已知 ...