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


相关推荐

  • jenkins demo //TODO「建议收藏」

    jenkins demo //TODO「建议收藏」mkdir-p/var/jenkins_mountchmod777/var/jenkins_mountdockerrun-d-p9091:8080-p9092:50000-v/var/jenkins_mount:/var/jenkins_mount-v/etc/localtime:/etc/localtime-v/usr/share/apache-maven/apache-maven-3.8.1:/usr/local/maven–namejenkinsjenk

    2022年6月2日
    28
  • quota什么意思(binding quota)

    什么是quotaquota的用途quota的一般作用对象quota的限制quota的使用重新挂devsdb1文件系统并添加usrquotagrpquota参数添加用户组和用户生成quota配置文件启动quota功能修改quota配置文件配置文件内容如下修改权限再写入一个大文件切换quota2用户修改警告时间查看quota1的quota信息查询quota2的quota信息

    2022年4月12日
    59
  • 前缀索引使用

    前缀索引使用前缀索引使用1.前缀索引索引通常会使用字段的整体用作关键字,但是有些时候,即使使用字段的前段部分数据也是可以去识别某些记录的,而这种方式就是前缀索引,可以更快的去搜索某些数据建立前缀索引的语法:ALTERTABLE表名ADDKEY(字段名(N));N就是要用字段的前几位建立索引。既然我们使用了前缀索引,那么我们肯定就要确认N为多少的时候的辨识度是极限接近最高辨识度的,否则前缀…

    2022年5月23日
    42
  • Mysql—— 内连接、左连接、右连接以及全连接查询

    Mysql—— 内连接、左连接、右连接以及全连接查询获取boy、girl表下载地址一、内连接查询innerjoin关键字:innerjoinon语句:select*froma_tableainnerjoinb_tablebona.a_id=b.b_id;说明:组合两个表中的记录,返回关联字段相符的记录,也就是返回两个表的交集(阴影)部分。案例解释:在boy表和girl表中查出…

    2022年4月26日
    33
  • Java web实现video播放

    Java web实现video播放javaweb实现video播放1.前端的实现通过getQueryVariable获取url的参数(vid)functiongetQueryVariable(variable){varquery=window.location.search.substring(1);varvars=query.split(“&”);for(v…

    2022年7月7日
    64
  • Jenkins(2)docker容器中安装python3[通俗易懂]

    Jenkins(2)docker容器中安装python3[通俗易懂]前言使用docker安装jenkins环境,jenkins构建的workspace目录默认是在容器里面构建的,如果我们想执行python3的代码,需进容器内部安装python3的环境。进jenki

    2022年7月28日
    26

发表回复

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

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