当前位置:网站首页>Andorid system layout, values, drawable adaptation
Andorid system layout, values, drawable adaptation
2022-07-28 19:52:00 【Alex_ designer】
andorid Screen adaptation
| Density type | Represents the resolution of (px) | Screen density (dpi) | conversion (px/dp) | The proportion |
|---|---|---|---|---|
| Low density (ldpi) | 240x320 | 120 | 1dp=0.75px | 3 |
| Medium density (mdpi) | 320x480 | 160 | 1dp=1px | 4 |
| high-density (hdpi) | 480x800 | 240 | 1dp=1.5px | 6 |
| Ultra high density (xhdpi) | 720x1280 | 320 | 1dp=2px | 8 |
| Ultra high density (xxhdpi) | 1080x1920 | 480 | 1dp=3px | 12 |
stay Android in , It is stipulated that 160dpi( That is, the screen resolution is 320x480) Benchmarking :1dp=1px
The preferred smallestWidth
smallestWidth Qualifiers fit
- The screen resolution qualifier is adapted according to the screen resolution ,Android The device resolution is a lot , But also consider the virtual keyboard , This requires a lot of dimens.xml file . Because no matter how many pixels the phone screen is , What is the density ,90% The minimum width of all mobile phones is 360dp, So using smallestWidth Qualifier adaptation requires only a small amount dimens.xml File can .
- The screen resolution qualifier adapts to px Company , and smallestWidth The unit of qualifier adaptation is dp and sp,dp and sp yes google Recommended unit of measurement . Because many applications require the font size to change with the system , So font units use sp And more flexible .
- Screen resolution qualifier adaptation requires device resolution and values-xx Only when the folders are completely matched can the adaptation be achieved , and smallestWidth Qualifier adaptation search dimens.xml The principle of documents is to look from big to small , For example, the minimum width of the equipment is 360dp, They'll look for it first values-360dp, If you don't find it, you will look down values-320dp, If you still don't have one, just find the default one values Under the demens.xml file , So even if there is no perfect match, it can achieve a good adaptation effect .
- Whether it's width or height , Which side is considered to be “ Minimum width ”
- Qualifier type :
- Size (size) qualifiers
- Minimum width (Smallest-width) qualifiers
- Layout alias
- Screen orientation (Orientation) qualifiers
Width and height qualifiers fit This practice is not recommended , such as 1920x1080 Your cell phone must be found 1920x1080 Qualifier for , Otherwise, you can only use the unified default dimens The file . If you use the default size ,UI It's likely to deform , In short , The fault tolerance mechanism is very poor .
1.layout-sw500dp
there sw representative smallwidth It means , When the absolute width of your screen is greater than 500dp when , The screen will automatically call layout-sw500dp The layout in the folder .
Be careful : The absolute width here refers to the actual width of the mobile phone , It has nothing to do with the horizontal and vertical screen of the mobile phone .
2.layout-w500dp
When the relative width of your screen is greater than 500dp when , The screen will automatically call layout-w500dp The layout in the folder .
Be careful : The relative width here refers to the relative width of the mobile phone ; That is, when the mobile phone vertical screen , Is the length of the smaller side ; When the phone is horizontal , Is the length of the longer side .
3.layout-h500dp
And layout-w500dp It's the same with , It just refers to the relative height .
Be careful : The relative height here refers to the relative height of the mobile phone ; That is, when the mobile phone vertical screen , Is the length of the longer side ; When the phone is horizontal , Is the length of the smaller side . But this approach is rarely used , Because the screen is at a relative height , That is, it can usually roll in the longitudinal direction, resulting in length change , Instead of being basically fixed in the horizontal direction , Therefore, this method has poor flexibility ,google Official documents suggest using this method as much as possible .
example : The density is 240 Size is :1280x720 and 1920x1080 Under which adapter folder should it be placed
Android in , It is stipulated that 160dpi( That is, the screen resolution is 320x480) Benchmarking
The corresponding density ratio is :
160 1
240 1.5
320 2
Use the minimum as the width :1280x720 yes 720,1920x1080 yes 1080
720/1.5 =480
1080/1.5 =720
sw480dp
sw720dp
layout Namely layout-sw720dp , yes values Namely values-sw720dp
Reference resources :
边栏推荐
- Leetcode Day2 consecutive numbers
- Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
- This customized keyboard turns me on~
- 彻底理解位运算——与(&)、非(~)、或(|)、异或(^)
- editor.md中markdown编辑器的实现
- BeanFactory not initialized or already closed - call ‘refresh‘ before accessing beans via the Applic
- Cloud computing notes part.1 - system management
- 为研发高端光刻胶,晶瑞股份斥资7500万元购买SK海力士的ASML光刻机
- Redis master-slave architecture (how to calculate sizeof function)
- STC12C5A60S2 function description (STC12C5A60S2 is triggered by default)
猜你喜欢

云计算笔记part.2——应用管理

Nips18 (AD) - unsupervised anomaly detection using geometric transformations using geometric augmentation

毕马威中国:证券基金经营机构信息技术审计项目发现洞察

Pagoda panel construction novel CMS management system source code measurement - thinkphp6.0

Leetcode Day1 score ranking

How openocd directly downloads programs to STM32 board through stlink (solved)

What parameters should be passed in calling integer or character array functions

【NPP安装插件】

Rust Getting Started Guide (rustup, cargo)

String中常用的API
随机推荐
China's first chip stamp released: built-in 120um ultra-thin NFC chip
shared_ptr 和 make_shared 的使用
2022年全国最新消防设施操作员(中级消防设施操作员)题库及答案
After reading the thesis for three years, I learned to read the abstract today
冲刺金九银十丨熬夜半个月汇集大厂Android岗1600道面试真题
How does app automated testing achieve H5 testing
Serial port receiving application ring buffer
亚马逊推出Amazon One手掌支付系统,非接触式掌静脉识别市场有望爆发
Pagoda panel construction novel CMS management system source code measurement - thinkphp6.0
Special draft of Mir | common sense knowledge and reasoning: representation, acquisition and application (deadline on October 31)
Cell review: single cell methods in human microbiome research
Edge detection and connection of image segmentation realized by MATLAB
leetcode day5 删除重复的电子邮箱
时间转日期的sql语句应该怎么写?
MySQL8 基于clone创建主从复制
基于MATLAB的函数拟合
Redis master-slave architecture (how to calculate sizeof function)
STC12C5A60S2 function description (STC12C5A60S2 is triggered by default)
MySQL8 tmp_ table_ Size and Max_ heap_ table_ size
并发程序设计,你真的懂吗?