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

<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的开头。 |
RelativeLayout.LayoutParams的更多相关文章
- RelativeLayout.LayoutParams.addRule()方法
1.应用场景 在使用RelativeLayout布局的时候,通常在载入布局之前在相关的XML文件中进行静态设置即可.但是,在有些情况下,我们需要动态的设置布局 的属性,在不同条件下设置不同的布局排列方 ...
- Android 动态改变布局属性RelativeLayout.LayoutParams.addRule()
我们知道,在 RelativeLayout 布局中有很多特殊的属性,通常在载入布局之前,在相关的xml文件中进行静态设置即可. 但是,在有些情况下,我们需要动态设置布局的属性,在不同的条件下设置不同的 ...
- 代码中动态改变布局属性RelativeLayout.LayoutParams.addRule()
我们知道,在 RelativeLayout 布局中有很多特殊的属性,通常在载入布局之前,在相关的xml文件中进行静态设置即可. 但是,在有些情况下,我们需要动态设置布局的属性,在不同的条件下设置不同的 ...
- java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.w ...
- java.lang.ClassCastException android.widget.RelativeLayout LayoutParams 异常
1.在xml布局文件如下所示: <RelativeLayout android:layout_width="match_parent" android:layout_heig ...
- 用代码设置 RelativeLayout.LayoutParams
1.注意 不能在RelativeLayout容器本身和他的子元素之间产生循环依赖,比如说,不能将RelativeLayout的高设置成为WRAP_CONTENT的时候将子元素的高设置成为 ALIGN_ ...
- Exception: java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
RelativeLayout title_bg = (RelativeLayout)FTU_Bluetooth.this.findViewById(R.id.titlebar); LinearLayo ...
- 为什么relativelayout.layoutParams的width为-1
源码里看下就知道了.. -1不代表宽度,代表MATCH_PARENT常量的值public static final int FILL_PARENT = -1; public static final ...
- java写RelativeLayout 的属性
有时项目需要动态的调整一下布局,需要改变一些view的位置属性等等. 直接下代码 RelativeLayout.LayoutParams params=new RelativeLayout.Layou ...
随机推荐
- 如何查看出口IP地址?
出口ip地址怎么看?#curl ifconfig.me
- 用UltraEdit判断打开文件的编码类型 用UltraEdit或notepad记事本查看文件编码格式 用UltraEdit查看当前文件编码
用UltraEdit查看当前文件编码 想判断文件的编码类型? 用强大的UltraEdit-32软件: UltraEdit-32的状态栏可以显示文件的编码类型,详细情况如下: ANSI/ANSCI--- ...
- ROS学习(四)—— 创建ROS Package
一.caktin Package的组成 1.必须含有 package.xml文件,提供有关程序包的元信息 2.必须含有一个catkin版本的 CmakeLists.txt文件,如果是一个catkin元 ...
- 两段检验系统生成的identityHashCode是否重复的代码
前言:承接上一篇hashCode和identityHashCode 的关系,下面的两段简单的程序主要是检验一下系统生成的identityHashCode是否存在重复的情况. 1:可以自由控制生成对象的 ...
- dbms_random.seed
语法: DBMS_RANDOM.SEED ( val IN BINARY_INTEGER); DBMS_RANDOM.SEED ( val IN VARCHAR2); val: Seed number ...
- Android静默安装实现方案,仿360手机助手秒装和智能安装功能
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/47803149 之前有非常多朋友都问过我.在Android系统中如何才干实现静默安装 ...
- Linux 定时任务【转载,整理】
目前,我已知的定时任务实现方法有两种:cron or systemd job,这里主要介绍cron的用法 一.crontab 简介 crontab命令的功能是在一定的时间间隔调度一些命令的执行.该命令 ...
- flowable 的ProcessEngine配置
1 flowable process engine 是通过 flowable.cfg.xml 配置文件配置的.在spring 环境中是使用 flowable-context.xml 配置文件的, P ...
- 安装/移除 MySQL 服务
MySQL Community Server 下载:https://dev.mysql.com/downloads/mysql/ 以下内容使用的版本为:mysql-5.7.17-win32.zip 1 ...
- [CTCI] 双栈排序
双栈排序 题目描述 请编写一个程序,按升序对栈进行排序(即最大元素位于栈顶),要求最多只能使用一个额外的栈存放临时数据,但不得将元素复制到别的数据结构中. 给定一个int[] numbers(C++中 ...