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)
上一篇 2022年7月1日 上午10:00
下一篇 2022年7月1日 上午10:00


相关推荐

  • warning用法_docker个人应用

    warning用法_docker个人应用docker本地化异常:/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

    2022年4月22日
    55
  • <Win32_15>用纯C语言来实现WP8中磁贴动态翻转的功能「建议收藏」

    今年年初入手了一部诺基亚新款WP8手机——Lumia620经典蓝,用起来感觉很不错,很流畅、界面很清新到现在,用了大概有大半年时间了,一直很好奇WP8中磁贴动态翻转的实现算法——使用过WP8手机的朋友都知道,这个功能很有3D的效果,看起来感觉很不错但是,它到底是如何实现的呢? 今儿,我就来和大家一起剖析一下它的实现细节WP8中磁贴动态翻转功能细节:(1)将当

    2022年4月13日
    67
  • nginx 静态文件配置(nginx常用配置)

    Nginx的配置文件nginx.conf配置详解如下:usernginxnginx;Nginx用户及组:用户组。window下不指定worker_processes8;工作进程:数目。根据硬件调整,通常等于CPU数量或者2倍于CPU。error_loglogs/error.log;error_loglogs/error.logno

    2022年4月14日
    73
  • html表单提交_html表单标签有哪些

    html表单提交_html表单标签有哪些1.表单属性设置<form>标签表示表单标签,定义整体的表单区域action属性设置表单数据提交地址method属性设置表单提交的方式,一般有“GET”方式和“POST”方式,不区分大小写2.表单元素属性设置name属性设置表单元素的名称,该名称是提交数据时的参数名value属性设置表单元素的值,该值是提交数据时参数名所对应的值3.示例代码<formaction=”https://www.baidu.com”method=”GET”>

    2026年4月14日
    7
  • matlab读取mnist数据集(c语言从文件中读取数据)

    mnistdatabase(手写字符识别)的数据集下载地:http://yann.lecun.com/exdb/mnist/。准备数据MNIST是在机器学习领域中的一个经典问题。该问题解决的是把28×28像素的灰度手写数字图片识别为相应的数字,其中数字的范围从0到9.共有四个文件需要下载:train-images-idx3-ubyte.gz,训练集,共60,000幅(28*28)的图像数据…

    2022年4月17日
    55
  • 四周第三次课(4月13日)

    四周第三次课(4月13日)

    2022年4月2日
    43

发表回复

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

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