我是靠谱客的博主 积极老师,这篇文章主要介绍绝对布局(AbsoluteLayout)的简单使用,现在分享给大家,希望可以做个参考。

随时随地阅读更多技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)

绝对布局是通过指定子组件的确切X、Y坐标来确定组件的位置。

布局XML:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="20px"
        android:layout_y="20px"
        android:text="A" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="60px"
        android:layout_y="20px"
        android:text="B" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="20px"
        android:layout_y="80px"
        android:text="C" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="60px"
        android:layout_y="80px"
        android:text="D" />

</AbsoluteLayout>


附上图片效果:

最后

以上就是积极老师最近收集整理的关于绝对布局(AbsoluteLayout)的简单使用的全部内容,更多相关绝对布局(AbsoluteLayout)内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(97)

评论列表共有 0 条评论

立即
投稿
返回
顶部