当前位置: 首页 > article >正文

RelativeLayout相对布局

activity_relative_layout.xml

<?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:layout_centerInParent="true"
        android:background="#ffffff"
        android:text="我 中间!"
        android:textColor="#000000"
        android:textSize="11sp" />

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

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

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

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

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

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

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

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

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

    <TextView
        android:id="@+id/tv_below_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/tv_center"
        android:layout_alignRight="@id/tv_center"
        android:background="#ffffff"
        android:text="我 在中间的下边!"
        android:textColor="#000000"
        android:textSize="11sp" />

</RelativeLayout>


http://www.kler.cn/news/285185.html

相关文章:

  • 使用 UniApp 实现摄像头视频流的接入并在页面上显示视频流
  • NC115.栈和排序_C++题解
  • python-word添加标题,段落,文字块
  • Web开发 Ajax 2024/3/31
  • 004、架构_计算节点
  • 科研绘图系列:R语言单细胞差异基因四分图(Quad plot)
  • 加密与安全_前后端通过AES-CBC模式安全传输数据
  • 【Python】运行tcl、perl程序
  • EasyExcel冲突问题,java.lang.NosuchFieldError: Factory
  • 《软件工程导论》(第6版)第4章 形式化说明技术 复习笔记
  • Xcode插件开发
  • 【机器学习】数据预处理-特征工程与特征选择
  • 数字芯片中I/O单元及电源domain布局中SIPI的考虑
  • 浅谈C#委托
  • zdppy+vue3+onlyoffice文档管理系统实战 20240828上课笔记 zdppy_cache框架完成和验证码框架继续优化
  • EmguCV学习笔记 VB.Net 第8章 图像分割
  • org.apache.commons.lang.math.NumberUtils#isNumber 解释
  • 大语言模型数据增强与模型蒸馏解决方案
  • 【最新华为OD机试E卷】空栈压数(200分)-多语言题解-(Python/C/JavaScript/Java/Cpp)
  • 【测试】——开发模型与测试模型
  • 黑神话 悟空 配置 Mac玩游戏
  • vue3中ref绑定的节点顺序错乱
  • day36
  • 【MySQL 12】事务管理 (带思维导图)
  • leetcode 147.对链表进行插入排序
  • Pr:代理预设
  • [E二叉树] lc110. 平衡二叉树(dfs+自底向上)
  • Java技术栈 —— Spark入门(二)之实时WordCount
  • 基于微信小程序的电动车租赁系统---附源码97332
  • 遇到的BUG及解决方法