Android开发学习笔记(六)相对布局RelativeLayout

案例效果:
在这里插入图片描述

源码:

<RelativeLayout android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content"
    >

    <TextView
        android:id="@+id/labe1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="相对布局"
        android:textSize="50sp">

    </TextView>

    <EditText
        android:id="@+id/et1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/labe1">

    </EditText>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/et1"
        android:text="OK"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"></Button>
</RelativeLayout>

在这里插入图片描述
在这里插入图片描述
两个值true对齐,false不对齐
相对某个控件layout_toLeftOfs (例子中没写)

总结:相对布局比较简单,主要注意每个控件取个id名即可

猜你喜欢

转载自blog.csdn.net/qq1198768105/article/details/113824164
今日推荐