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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Python贪吃蛇 (完整代码+详细注释+粘贴即食)

    Python贪吃蛇 (完整代码+详细注释+粘贴即食)代码#!/usr/bin/envpython#-*-coding:utf-8-*-#author:Wangdalitime:2021年1月24日16:08:44#python实现:贪吃蛇”’游戏玩法:回车开始游戏;空格暂停游戏/继续游戏;方向键/wsad控制小蛇走向”””思路:用列表存储蛇的身体;用浅色表示身体,深色背景将身体凸显出来;蛇的移动:仔细观察,是:身体除头和尾不动、尾部消失,头部增加,所以,新添加的元素放在列表头部、删除尾部元素;游戏结束判定策略:超出

    2022年5月15日
    36
  • voliate理解

    voliate理解voliatevoliate定义java编程语言允许线程访问共享变量,为了确保共享变量能被准确和一致的更新,线程应该确保通过排他锁单独获得这个变量。Java语言提供了volatile,在某些情况下比锁更加方便。如果一个字段被声明成volatile,java线程内存模型确保所有线程看到这个变量的值是一致的。volatile可以保证线程可见性且提供了一定的有序性,但是无法保证原子性。在JVM…

    2022年6月5日
    108
  • mysql基本命令

    mysql基本命令这里把自己学的mysql数据库的知识总结一下,当是给自己复习一遍,也是方便以后查询安装和配置mysql就不说了,可以借鉴这位博友的安装过程https://www.cnblogs.com/by330

    2022年7月3日
    19
  • win10 任务栏锁定,win键没反应

    win10 任务栏锁定,win键没反应现象:之前用win10,换成win10专业版后,安装360优化系统,过了几天后突然发现任务栏好像被锁定一般,按windows键没有任何反应,任务栏打开的文件,图片等等右键也没有反应,讲道理应该有关闭选项的,再次检查发现日期点不开,看不到日历,音量键点了也没有反应。各种百度总之各种找原因都没有找到,直到看到一篇文章才解决问题,原来win10与win7的管理机制不同,不能关闭防火墙的。…

    2022年6月4日
    52
  • for循环将字典添加到列表中出现覆盖前面数据的问题

    for循环将字典添加到列表中出现覆盖前面数据的问题

    2021年5月24日
    110
  • linux chmod 755 ,750,777

    linux chmod 755 ,750,777一直没用过chmod777(755,750)的命令,也不知道具体是什么作用,尤其不知道755,750,777分别代表什么意思,只记得有一次咨询一个同门时告诉我不要设置成777模式,后来就没有接触了。因为今天又用到了,所以整理归纳以一下。chmod是Linux下设置文件夹权限的命令,后面一般跟三个数据,代表不用用户群体在这个文件夹上的权限设置:一般是三个数字:chmod750dir_wzg第一个数字表示文件所有者的权限第二个数字表示文件所有者同属一个用户组的其他用户在该文件上的权限

    2022年7月16日
    38

发表回复

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

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