gpt4 book ai didi

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

转载 作者:qq735679552 更新时间:2022-09-27 22:32:09 26 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章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 中的控件居中 。

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

layout_width="fill_parent" ,自动填充至屏幕宽度,layout_height 同理 。

layout_width="wrap_content" ,自动填充为控件大小,layout_height 同理 。

linearlayout ,在android入门实例一篇所用的layout 就是linearlayout ,它的理解很简单:在linearlayout 里面的控件,按照水平或者垂直排列: orientation="horizontal" :水平排列;orientation=" vertical" :垂直排列 当linearlayout 是horizontal ,并且里面的控件使用了layout_width="fill_parent" ,第二组控件会挡在屏幕的右边,那也就是看不到了.

absolutelayout ,是一个按照绝对坐标定义的布局,由于使用绝对坐标去定位控件,因此要实现自适应界面时,应尽少使用 absolutelayout 。 absolutelayout 里面的控件都以layout_x 、layout_y 来定义其位置:

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

上图中的textview01的x坐标为10px,y坐标为10px,页面布局代码如下:

?
1
2
3
4
<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>

  。

最后此篇关于Android入门之LinearLayout、AbsoluteLayout的用法实例讲解的文章就讲到这里了,如果你想了解更多关于Android入门之LinearLayout、AbsoluteLayout的用法实例讲解的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com