安卓相对布局RelativeLayout

 

 

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

    <TextView
        android:id="@+id/tv_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_centerInParent="true"
        android:text="我在中间"
        android:textSize="11sp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tv_herizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_centerHorizontal="true"
        android:text="我在水平中间"
        android:textSize="11sp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tv_vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_centerVertical="true"
        android:text="我在垂直中间"
        android:textSize="11sp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tv_parent_left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_alignParentLeft="true"
        android:text="我跟上级左边对齐"
        android:textSize="11sp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tv_parent_right"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_alignParentRight="true"
        android:text="我跟上级右边对齐"
        android:textSize="11sp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tv_parent_top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_alignParentTop="true"
        android:text="我跟上级顶部对齐"
        android:textSize="11sp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tv_parent_bottom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_alignParentBottom="true"
        android:text="我跟上级底部对齐"
        android:textSize="11sp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tv_left_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_toLeftOf="@id/tv_center"
        android:layout_alignTop="@id/tv_center"
        android:text="我在中间左边"
        android:textSize="11sp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tv_right_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_toRightOf="@id/tv_center"
        android:layout_alignBottom="@id/tv_center"
        android:text="我在中间右边"
        android:textSize="11sp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tv_below_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:layout_above="@id/tv_center"
        android:layout_alignLeft="@id/tv_center"
        android:text="我在中间上边"
        android:textSize="11sp"
        android:textColor="#000000"/>

</RelativeLayout>

相关推荐

最近更新

  1. 强化OT安全英国发布工控网络事件响应实践指南

    2024-02-01 13:30:06       0 阅读
  2. 使用静态图加速

    2024-02-01 13:30:06       0 阅读
  3. 修改ES索引名称

    2024-02-01 13:30:06       0 阅读
  4. asp.netWebForm(.netFramework) CSRF漏洞

    2024-02-01 13:30:06       0 阅读
  5. Redis的使用(三)常见使用场景-session共享

    2024-02-01 13:30:06       0 阅读
  6. DS200CVMAG1AEB处理器 控制器 模块

    2024-02-01 13:30:06       1 阅读
  7. 插8张显卡的服务器有哪些?

    2024-02-01 13:30:06       1 阅读
  8. react antd table拖拽

    2024-02-01 13:30:06       1 阅读
  9. VB 关键字

    2024-02-01 13:30:06       1 阅读
  10. 前端面试题(13)答案版

    2024-02-01 13:30:06       1 阅读

热门阅读

  1. 开源模型应用落地-业务优化篇(二)

    2024-02-01 13:30:06       26 阅读
  2. 深入理解Django与Redis的集成实践

    2024-02-01 13:30:06       31 阅读
  3. 2401cmake,学习cmake1

    2024-02-01 13:30:06       39 阅读
  4. JeecgBoot-vue3--JDictSelectTag去掉选项中得‘请选择’

    2024-02-01 13:30:06       39 阅读
  5. 微信小程序如何控制元素的显示和隐藏

    2024-02-01 13:30:06       29 阅读
  6. sql 计算工作日数

    2024-02-01 13:30:06       29 阅读
  7. UCL-ELEC0136: Data Acquisition and Processing Systems

    2024-02-01 13:30:06       29 阅读
  8. 单例模式

    2024-02-01 13:30:06       31 阅读