版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ancientear/article/details/82532606
添加一个< AbsoluteLayout>绝对布局管理器,然后分别添加一个TextView组件和一个Button组件,并分别通过android:layout_x和android:layout_y属性设置它们的绝对位置。
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.shenfan.absolutelayout.MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="20px"
android:layout_y="10px"
android:text="用户名"
/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_x="50px"
android:layout_y="100px"
android:text="确定"/>
</AbsoluteLayout>