Android 的UI 布局都以Layout 作为容器,在上面按照规定排列控件,这方面跟JAVA 的Swing 和LWUIT 很像。控件跟Layout 有很多属性是一样的,可以在Properties 里面修改,跟.NET/Delphi 等RAD 类似,其中最常用的属性有以下这些:
id="@+id/edtInput",ID 是连接UI 与代码的桥梁
Gravity= "center" ,Layout 中的控件居中
layout_width="fill_parent" ,自动填充至屏幕宽度,layout_height 同理
layout_width="wrap_content" ,自动填充为控件大小,layout_height 同理
LinearLayout ,在入门第一篇所用的Layout 就是LinearLayout ,它的理解很简单:在LinearLayout 里面的控件,按照水平或者垂直排列:
orientation="horizontal" :水平排列;orientation=" vertical" :垂直排列
当LinearLayout 是horizontal ,并且里面的控件使用了layout_width="fill_parent" ,第二组控件会挡在屏幕的右边,那也就是看不到了。。。
AbsoluteLayout ,是一个按照绝对坐标定义的布局,由于使用绝对坐标去定位控件,因此要实现自适应界面时,应尽少使用 AbsoluteLayout 。 AbsoluteLayout 里面的控件都以layout_x 、layout_y 来定义其位置:
上图中的TextView01的X坐标为10px,Y坐标为10px:
- <AbsoluteLayoutandroid:id="@+id/AbsoluteLayout01"android:layout_height="wrap_content"android:layout_width="fill_parent">
-
<TextViewandroid:text="TextView01"android:id="@+id/TextView01"android:layout_height="wrap_content"android:layout_y="10px"android:layout_width="wrap_content"android:layout_x="110px">
-
</TextView>
-
</AbsoluteLayout>
分享到:
相关推荐
Android入门第二篇之LinearLayout、AbsoluteLayout.docx
主要介绍了Android入门之LinearLayout、AbsoluteLayout的用法,对于Android初学者有很好的参考借鉴价值,需要的朋友可以参考下
第一讲:Android开发环境...第二十六讲:Android中的GPS应用入门 第二十七讲:Handler使用入门 第二十八讲:Android多媒体(Media)入门 第二十九讲:WebView学习指南 第三十讲:URLConnection和HttpClient使用入门
Android开发完全讲义(第二版)第四文章之linearlayout源代码 作者:李宁
关于linearlayout布局案例
android 2.2计算器小实例,LinearLayout,listener
android linearlayout 学习
android demo,自定义LinearLayout的实现。
Android源码LinearLayout实例,经典代码,是学习Android的好东西
在做android UI布局时,用了LinearLayout嵌套,发现效果并不如我预料一般 查了下资料,说是要设置layout_weight属性 资料说得不是很清楚,也没仔细看,就去弄,结果越弄越混乱。 于是静下心来,自己写xml测试,发现...
Android 跑马灯,用LinearLayout加动画实现。参见博客文章http://blog.csdn.net/u012587637/article/details/41694765
Android移动应用开发线性布局LinearLayout的常用属性.pdf 学习资料 复习资料 教学资源
Android开源代码,自定义Layout,继承自LinearLayout,内部控件自动换行显示。例如:可用来开发数量变化的属性标签群。
Android移动应用开发线性布局LinearLayout的weight属性简介.pdf 学习资料 复习资料 教学资源
Android 应用开发源码 参考与学习使用
第2章 搭建Android开发环境 2.1 Android开发环境要求 2.2 JDK的安装和配置 2.2.1 安装JDK 2.2.2 配置JDK 2.3 Android SDK的下载和安装 2.3.1 下载Android SDK 2.3.2 安装Android SDK 2.3.3 创建Android虚拟设备 2.4 ...
android demo,LinearLayout的事件的的处理,LinearLayout的显示的隐藏。
主要为大家详细介绍了Android LinearLayout实现自动换行效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
Android 的入门开发帮助文档,能够更容易的帮你理解和使用LinearLayout的语法