国外网站卖货平台,学校网站首页设计图片,搜狗竞价绑定网站要求,河南省台前县建设局网站绝对布局:需要指定子元素的 x#xff0c;y 精确坐标的布局。 缺点#xff1a; 绝对布局缺乏灵活性#xff0c;在没有绝对定位的情况下相比其他类型的布局更难维护#xff0c;不建议使用。 因为绝对布局,我们开发的应用需要在很多的机型上面进行一个适配,如果使用了这个绝对…绝对布局:需要指定子元素的 xy 精确坐标的布局。 缺点 绝对布局缺乏灵活性在没有绝对定位的情况下相比其他类型的布局更难维护不建议使用。 因为绝对布局,我们开发的应用需要在很多的机型上面进行一个适配,如果使用了这个绝对布局的话,可能你在4寸的手机上是显示正常的,而换成5寸的手机,就可能出现偏移和变形 目前的Android Studio上使用时候会显示以弃用的标示
常用属性
属性作用android:layout_width组件宽度android:layout_height组件高度android:layout_x设置组件的X坐标android:layout_y设置组件的Y坐标
这些属性比较简单使用起来也比较简单易懂。
实例
?xml version1.0 encodingutf-8?
AbsoluteLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:context.AbsoluteLayoutActivityTextViewandroid:layout_width200dpandroid:layout_height100dpandroid:layout_x110dpandroid:text绝对布局android:textSize50dpandroid:gravitycenter/ImageViewandroid:layout_width100dpandroid:layout_height100dpandroid:layout_x50dpandroid:layout_y150dpandroid:srcdrawable/img_2/ImageViewImageViewandroid:layout_width100dpandroid:layout_height100dpandroid:layout_x50dpandroid:layout_y300dpandroid:srcdrawable/img/ImageViewImageViewandroid:layout_width100dpandroid:layout_height100dpandroid:layout_x50dpandroid:layout_y450dpandroid:srcdrawable/zy/ImageViewButtonandroid:layout_width100dpandroid:layout_height50dpandroid:layout_x250dpandroid:layout_y150dpandroid:backgrounddrawable/img_2android:text按钮1/ButtonButtonandroid:layout_width100dpandroid:layout_height50dpandroid:layout_x250dpandroid:layout_y300dpandroid:backgrounddrawable/imgandroid:text按钮2/ButtonButtonandroid:layout_width100dpandroid:layout_height50dpandroid:layout_x250dpandroid:layout_y450dpandroid:backgrounddrawable/zyandroid:text按钮3/ButtonTextViewandroid:layout_width200dpandroid:layout_height100dpandroid:layout_x110dpandroid:layout_y550dpandroid:text通过layout_x和layout_y来调节位置android:textSize20dpandroid:textStyleboldandroid:gravitycenter//AbsoluteLayout
效果 绝对布局是前端布局中最为简单的布局但灵活性极差不具有自动适应设备分辨率的能力就好比在手机上设置的布局在平板上布局就会全部混乱所以在日常开发中很少使用绝对布局。