【Android(安卓)开发教程】AbsoluteLayout绝对布局
16lz
2021-01-24
本章节翻译自《Beginning-Android-4-Application-Development》,如有翻译不当的地方,敬请指出。
原书购买地址http://www.amazon.com/Beginning-Android-4-Application-Development/dp/1118199545/使用AbsoluteLayout,可以指定它其中的子View的确切位置。观察如下main.xml中的代码:
[html] view plain copy- <?xmlversion="1.0"encoding="utf-8"?>
- <AbsoluteLayoutxmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <Button
- android:layout_width="188dp"
- android:layout_height="wrap_content"
- android:layout_x="126px"
- android:layout_y="361px"
- android:text="Button"/>
- <Button
- android:layout_width="113dp"
- android:layout_height="wrap_content"
- android:layout_x="12px"
- android:layout_y="361px"
- android:text="Button"/>
- </AbsoluteLayout>
但当activity被绘制在一个高分辨率的屏幕上时,AbsoluteLayout就会出现某些问题。
下图是,在使用同样代码的前提下,高分辨率屏幕上显示出来的效果。
出于这个原因,从Android1.5开始,Google官方已经不推荐使用这个布局了,尽管它现在还是可以使用的。在创建UI的时候,应该避免使用AbsoluteLayout这个布局,因为,Android并不确保会在将来的版本中还继续支持它。更多相关文章
- android文件、资源读取总结
- Android(安卓)Listview切换动画,扩展到任意view切换之间动画实现
- Android几行代码解决键盘遮挡问题
- Android实现沉浸式状态栏
- android通过自定义toast实现悬浮通知效果的示例代码
- Fragment 在Android(安卓)SDK1.6上实现
- android studio开发教程 ListActivity的2种使用方法:系统默认布局
- Android(安卓)gradle和gradle插件配置
- Android(安卓)fill_parent和wrap_content分析