健康一贴灵,专注医药行业管理信息化

Android 相对布局RelativeLayout 代码示例

文字分别放在左上,右上,中间,左下,右下五个地方;

 

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <TextView
        style="@style/RelativeLayoutDemo1Item"
        android:text="default" />

    <TextView
        style="@style/RelativeLayoutDemo1Item"
        android:layout_alignParentEnd="true"
        android:text="layout_alignParentEnd" />

    <TextView
        style="@style/RelativeLayoutDemo1Item"
        android:layout_centerInParent="true"
        android:text="layout_centerInParent" />

    <TextView
        style="@style/RelativeLayoutDemo1Item"
        android:layout_alignParentBottom="true"
        android:text="layout_alignParentBottom" />

    <TextView
        style="@style/RelativeLayoutDemo1Item"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:text="layout_alignParentBottom | End" />
</RelativeLayout>

 

posted @ 2024-04-10 11:44  一贴灵  阅读(37)  评论(0编辑  收藏  举报
学以致用,效率第一