RelativeLayout.LayoutParams

RelativeLayout.LayoutParams通过id设置相对兄弟元素对齐。<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android&qu

大家好,又见面了,我是你们的朋友全栈君。

通过id设置相对兄弟元素对齐。

 <span role="heading" aria-level="2">RelativeLayout.LayoutParams

 

<span role="heading" aria-level="2">RelativeLayout.LayoutParams
<span role="heading" aria-level="2">RelativeLayout.LayoutParams

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

    <TextView
        android:id="@+id/lyla_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:textSize="24sp"
        android:text="Lyla" />

    <TextView
        android:id="@+id/me_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@id/lyla_text_view"
        android:textSize="24sp"
        android:text="Me" />

    <TextView
        android:id="@+id/natalie_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/lyla_text_view"
        android:textSize="24sp"
        android:text="Natalie" />

    <TextView
        android:id="@+id/jennie_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:textSize="24sp"
        android:text="Jennie" />

    <TextView
        android:id="@+id/omoju_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_above="@id/jennie_text_view"
        android:textSize="24sp"
        android:text="Omoju" />

    <TextView
        android:id="@+id/amy_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_above="@id/omoju_text_view"
        android:layout_alignParentRight="true"
        android:textSize="24sp"
        android:text="Amy" />

    <TextView
        android:id="@+id/ben_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:textSize="24sp"
        android:text="Ben" />

    <TextView
        android:id="@+id/kunal_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@id/ben_text_view"
        android:textSize="24sp"
        android:text="Kunal" />

    <TextView
        android:id="@+id/kagure_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_toRightOf="@id/ben_text_view"
        android:textSize="24sp"
        android:text="Kagure" />

</RelativeLayout>

相对兄弟节点(id)放置

 

 

XML属性

android:layout_above 将此视图的下边缘定位在给定锚点视图ID上方。 
android:layout_alignBaseline 将此视图的基线定位在给定锚点视图ID的基线上。 
android:layout_alignBottom 使此视图的下边缘与给定锚点视图ID的下边缘匹配。 
android:layout_alignEnd 使此视图的结束边缘与给定锚点视图ID的结束边缘匹配。 
android:layout_alignLeft 使此视图的左边缘与给定锚点视图ID的左边缘匹配。 
android:layout_alignParentBottom 如果为true,则使此视图的下边缘与父级的下边缘匹配。 
android:layout_alignParentEnd 如果为true,则使此视图的结束边缘与父级的结束边缘匹配。 
android:layout_alignParentLeft 如果为true,则使此视图的左边缘与父窗口的左边缘匹配。 
android:layout_alignParentRight 如果为true,则使此视图的右边缘与父级的右边缘匹配。 
android:layout_alignParentStart 如果为true,则使此视图的起始边缘与父级的起始边缘匹配。 
android:layout_alignParentTop 如果为true,则使此视图的上边缘与父级的上边缘匹配。 
android:layout_alignRight 使此视图的右边缘与给定锚点视图ID的右边缘匹配。 
android:layout_alignStart 使此视图的起始边缘与给定锚点视图ID的起始边缘匹配。 
android:layout_alignTop 使此视图的上边缘与给定锚点视图ID的上边缘匹配。 
android:layout_alignWithParentIfMissing 如果设置为true,则在无法找到layout_toLeftOf,layout_toRightOf等的锚点时,父项将用作锚点。 
android:layout_below 将此视图的上边缘定位在给定锚点视图ID下方。 
android:layout_centerHorizontal 如果为true,则将此子项水平居中于其父级。 
android:layout_centerInParent 如果为true,则将此子项在其父级中水平和垂直居中。 
android:layout_centerVertical 如果为true,则将此子项垂直居中于其父项中。 
android:layout_toEndOf 将此视图的起始边缘定位到给定锚点视图ID的末尾。 
android:layout_toLeftOf 将此视图的右边缘定位在给定锚点视图ID的左侧。 
android:layout_toRightOf 将此视图的左边缘定位到给定锚点视图ID的右侧。 
android:layout_toStartOf 将此视图的结束边缘定位到给定锚点视图ID的开头。 
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/154769.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • MariaDB安装教程

    MariaDB安装教程注:从MariaDB10.4.3开始,不再提供预构建的数据目录,并且用户需要运行mysql_install_db.exe来创建数据目录1、解压到自定义路径E:\MariaDB\mariadb-10.5.4-winx642、将其中的bin加入path系统环境路径3、用管理员方式打开cmd,并打开bin目录4、输入mysql_install_db.exe–datadir=E:\MariaDB\mariadb-10.5.4-winx64\data–service=MyMar..

    2022年6月14日
    30
  • 组合数常用计算公式

    组合数常用计算公式Cnm=n!m!∗(n−m)!C_n^m=\frac{n!}{m!*(n-m)!}Cnm​=m!∗(n−m)!n!​Cn2=n∗(n−1)2C_n^2=\frac{n*(n-1)}{2}Cn2​=2n∗(n−1)​Cn3=n∗(n−1)∗(n−2)6C_n^3=\frac{n*(n-1)*(n-2)}{6}Cn3​=6n∗(n−1)∗(n−2)​Cnm=Cn−1m−1+Cn−1mC_n^m…

    2022年7月25日
    10
  • Mac 安装 node.js 及环境配置[通俗易懂]

    Mac 安装 node.js 及环境配置[通俗易懂]目录安装node1:官网下载2:安装3:验证4:环境配置安装node1:官网下载访问nodejs官网,点击蓝色选框区域稳定版,并下载https://nodejs.org/en2:安装双击刚下载的文件,按步骤默认安装就行3:验证安装完成后打开终端输入npm-vnode-v两个命令,如下图出现版本信息,说明安装成功4:环境配置1:打开Mac终端,配置全局环境变量vim.bash_profile2:打开之后添加一行以下代码,(Mac的node,npm可执行文件都在/usr

    2022年5月13日
    59
  • 【推荐】mysql联合 索引(复合索引)的探讨

    【推荐】mysql联合 索引(复合索引)的探讨 Mysql联合索引(复合索引)的使用原则 命名规则:表名_字段名需要加索引的字段,要在where条件中。 数据量少的字段不需要加索引。最窄的字段放在键的左边。 如果where条件中是OR关系,必须所有的or条件都必须是独立索引,否则加索引不起作用。见:mysql关于or的索引问题 最左匹配原则。 只要列中包含有NULL值都将不会被包含在索引中,复合索引中只要有一列含有NULL…

    2022年5月18日
    60
  • 2015阿里校招前端在线题目[通俗易懂]

    2015阿里校招前端在线题目

    2022年1月27日
    45
  • 机器人slam技术_激光二维扫描仪

    机器人slam技术_激光二维扫描仪机器人开发–二维激光SLAM介绍1SLAM简介1.1概述1.2应用1.3历史发展2SLAM中3个模块2.1前端里程计模块实现原理实现方法2.2后端优化模块2.3回环检测模块参考1SLAM简介1.1概述SLAM本质就是确定自己在哪里的哪里,如在苏州中心的正东边66米处。SLAM(SimultaneousLocalizationandMapping),也称为CML(ConcurrentMappingandLocalization),即时定位与地图构建,或并发

    2022年8月23日
    6

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号