源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android入门之LinearLayout、AbsoluteLayout的用法实例讲解

  • 时间:2022-11-02 14:01 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android入门之LinearLayout、AbsoluteLayout的用法实例讲解
本文实例介绍了Android中LinearLayout、AbsoluteLayout的用法,希望能对于初学Android的朋友起到一点帮助作用。具体内容如下: Android 的UI 布局都以Layout 作为容器,并且在上面按照规定排列控件,这方面跟JAVA 的Swing 和LWUIT 很像。控件跟Layout 有很多属性是一样的,可以在Properties 里面修改,跟.NET/Delphi 等RAD 类似,其中最常用的属性有以下这些: id="@+id/edtInput",ID 是连接UI 与代码的桥梁 Gravity= "center" ,Layout 中的控件居中 [img]http://files.jb51.net/file_images/article/201408/20148885444137.jpg?20147885634[/img] layout_width="fill_parent" ,自动填充至屏幕宽度,layout_height 同理 [img]http://files.jb51.net/file_images/article/201408/20148885505924.jpg?20147885622[/img] layout_width="wrap_content" ,自动填充为控件大小,layout_height 同理 [img]http://files.jb51.net/file_images/article/201408/20148885517462.jpg?20147885611[/img] LinearLayout ,在[url=http://www.1sucai.cn/article/53414.htm]Android入门实例[/url]一篇所用的Layout 就是LinearLayout ,它的理解很简单:在LinearLayout 里面的控件,按照水平或者垂直排列: orientation="horizontal" :水平排列;orientation=" vertical" :垂直排列 当LinearLayout 是horizontal ,并且里面的控件使用了layout_width="fill_parent" ,第二组控件会挡在屏幕的右边,那也就是看不到了。 AbsoluteLayout ,是一个按照绝对坐标定义的布局,由于使用绝对坐标去定位控件,因此要实现自适应界面时,应尽少使用 AbsoluteLayout 。 AbsoluteLayout 里面的控件都以layout_x 、layout_y 来定义其位置: [img]http://files.jb51.net/file_images/article/201408/20148885529349.jpg?20147885559[/img]   上图中的TextView01的X坐标为10px,Y坐标为10px,页面布局代码如下:
<AbsoluteLayout android:id="@+id/AbsoluteLayout01" android:layout_height="wrap_content" android:layout_width="fill_parent" > 
<TextView android: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>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部