当前位置:网站首页>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>
边栏推荐
- Fuzzy -- basic application method of AFL
- Delete subsequence < daily question >
- The web project imported the MySQL driver jar package but failed to load it into the driver
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Drive development - the first helloddk
- Compilation et connexion de shader dans games202 - webgl (comprendre la direction)
- MySQL reported an error datetime (0) null
- [buuctf.reverse] 159_ [watevrCTF 2019]Watshell
- SQL注入漏洞(MSSQL注入)
- Postman断言
猜你喜欢

acwing周赛58

Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago

ORM aggregate query and native database operation

Introduction of several RS485 isolated communication schemes

二叉树基本知识和例题

Delete subsequence < daily question >

Cve-2019-11043 (PHP Remote Code Execution Vulnerability)

你需要知道的 TCP 三次握手

JS quick start (II)

idea一键导包
随机推荐
The kernel determines whether peripherals are attached to the I2C address
Drive development - the first helloddk
关于imx8mp的es8316的芯片调试
RTP gb28181 document testing tool
Application of Flody
Fiddler installed the certificate, or prompted that the certificate is invalid
[noip2008 improvement group] stupid monkey
Microservice resource address
Redis 排查大 key 的4種方法,優化必備
2021robocom robot developer competition (Preliminary)
Redis has four methods for checking big keys, which are necessary for optimization
TCP three handshakes you need to know
Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
优秀PM必须经历这3层蜕变!
最高法院,离婚案件判决标准
What should the project manager do if there is something wrong with team collaboration?
Three.js学习-光照和阴影(了解向)
Platformio create libopencm3 + FreeRTOS project
ISP learning (2)
[FreeRTOS interrupt experiment]