[英]How to create responsive layout for phones with different screen sizes but same density?
I am trying to create a layout suitable for HDPI scree of size 4" and 5.99".我正在尝试创建适合尺寸为 4" 和 5.99" 的 HDPI 碎石的布局。 But I tried using density qualifier but it did not work as the things would go out of the layout in 4 or seem small in 5 inch screen.
但是我尝试使用密度限定符,但它不起作用,因为 go 会超出 4 的布局或在 5 英寸屏幕中看起来很小。 How can I avoid it?
我怎样才能避免它?
I had faced this issue before and I suggest you to use sdp
and ssp
instead of dp
and sp
.我之前遇到过这个问题,我建议你使用
sdp
和ssp
而不是dp
和sp
。
You'll have to add dependency
in your gradle script
您必须在
gradle script
中添加dependency
项
For ssp
对于
ssp
implementation 'com.intuit.ssp:ssp-android:1.1.0'
For sdp
对于
sdp
implementation 'com.intuit.sdp:sdp-android:1.1.0'
Note :Do not use wrap_content
for images
and buttons
while using sdp.注意:不要在使用 sdp 时将
wrap_content
用于images
和buttons
。 If you do, when running in small device, the system will wrap up the image without considering the size of the screen.如果这样做,在小型设备上运行时,系统会在不考虑屏幕大小的情况下将图像包裹起来。 So use specific
sdp
for images and buttons.因此,对图像和按钮使用特定的
sdp
。
For tablets, consider creating different layout and for landscape mode in phone, if its not necessary disable the option, or create new layout.对于平板电脑,考虑在手机中创建不同的布局和横向模式,如果没有必要禁用该选项,或创建新布局。
If you want to learn more about ssp
and sdp
如果您想了解有关
ssp
和sdp
的更多信息
for ssp
对于
ssp
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiGmMHIk-L5AhUGSGwGHU1WCRsQFnoECAcQAQ&url=https%3A%2F%2Fgithub.com%2Fintuit%2Fssp&usg=AOvVaw2ZMN5twdYDhgEafciw5fhV https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiGmMHIk-L5AhUGSGwGHU1WCRsQFnoECAcQAQ&url=https%3A%2F%2Fgithub.com%2Fintuit%2Fssp&usg=AOvVaw2ZMN5twdYDhgEafciw5fhV
for sdp
对于
sdp
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjb9rqclOL5AhXYzTgGHdP5BZIQFnoECAYQAQ&url=https%3A%2F%2Fgithub.com%2Fintuit%2Fsdp&usg=AOvVaw21fhKo_QcSaG-J1OIXCylC https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjb9rqclOL5AhXYzTgGHdP5BZIQFnoECAYQAQ&url=https%3A%2F%2Fgithub.com%2Fintuit%2Fsdp&usg=AOvVaw21fhKo_QcSaG-J1OIXCylC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.