当前位置:网站首页>February 12 relativelayout
February 12 relativelayout
2022-07-06 04:59:00 【Double 0】
1. Relative layout starts from the upper left corner of the interface , Therefore, the latter of two consecutive relative layouts will mask the former
for example , Red is covered by green 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:background="#ff0000"
android:layout_width="100dp"
android:layout_height="100dp"/>
<RelativeLayout
android:background="#00ff00"
android:layout_width="100dp"
android:layout_height="100dp"/>
</RelativeLayout>
2. Locate according to the parent container ( Based on the outermost layer )
Show the red 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:background="#ff0000"
android:layout_alignParentRight="true"
android:layout_width="100dp"
android:layout_height="100dp"/>
<RelativeLayout
android:background="#00ff00"
android:layout_width="100dp"
android:layout_height="100dp"/>
</RelativeLayout>
3. Locate according to the container
Because there are many brother containers , So which one should be set id
Set the red layout id
android:id="@+id/rl1"
Note that @+id
The green layout is @id
android:layout_toLeftOf="@id/rl1"
4. Set the margin between the component and the parent container
Distance from left 100dp
android:layout_marginLeft="100dp"

Up, down, left and right offset 100dp
android:layout_margin="100dp"

5. Set the margin of elements inside the component 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="100dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/rl1"
android:background="#ff0000"
android:layout_centerInParent="true"
android:layout_width="100dp"
android:layout_height="100dp"/>
<RelativeLayout
android:background="#00ff00"
android:layout_width="100dp"
android:layout_height="100dp"/>
</RelativeLayout>
边栏推荐
- [lgr-109] Luogu may race II & windy round 6
- Chip debugging of es8316 of imx8mp
- 也算是學習中的小總結
- SQL注入漏洞(MSSQL注入)
- [buuctf.reverse] 159_[watevrCTF 2019]Watshell
- 關於Unity Inspector上的一些常用技巧,一般用於編輯器擴展或者其他
- [detailed steps of FreeRTOS shift value for the first time]
- Flody的应用
- Postman pre script - global variables and environment variables
- 饼干(考试版)
猜你喜欢

SQL injection vulnerability (MSSQL injection)

Compilation et connexion de shader dans games202 - webgl (comprendre la direction)

二叉树基本知识和例题

Delete subsequence < daily question >

Orm-f & Q object

Leetcode dynamic planning day 16

Why does MySQL need two-phase commit

IPv6 comprehensive experiment

Lepton 无损压缩原理及性能分析

Sqlserver query results are not displayed in tabular form. How to modify them
随机推荐
Pagoda configuration mongodb
MySQL reported an error datetime (0) null
JS quick start (II)
2021robocom robot developer competition (Preliminary)
你需要知道的 TCP 三次握手
Sqlserver query results are not displayed in tabular form. How to modify them
Finance online homework
Driver development - hellowdm driver
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
Digital children < daily question> (Digital DP)
Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected
MySQL time processing
Why does MySQL need two-phase commit
Chip debugging of es8316 of imx8mp
Nestjs配置文件上传, 配置中间件以及管道的使用
Quick sort
Simple understanding of interpreters and compilers
[FreeRTOS interrupt experiment]
Class inheritance in yyds dry inventory C
What should the project manager do if there is something wrong with team collaboration?