[英]Resizing image height and width according to device screen
How can i display my image on the full screen of different devices ie auto adjusting the image according to device display? 如何在不同设备的全屏上显示我的图像,即根据设备显示自动调整图像?
I have tried "Width : Device-width" option but didn't succeed. 我尝试了“宽度:设备宽度”选项,但未成功。 Any help?
有什么帮助吗?
I found the solution for this. 我找到了解决方案。 I follow the "@media queries" concept in my css and it done the trick for me.
我在CSS中遵循“ @media查询”的概念,它为我完成了窍门。
check if this css helps your code!! 检查此CSS是否有助于您的代码!
html, body {
width:100%; /* this is a must */
height:100%; /* this is a must */
margin:0;
padding:0;
}
img {
width:100%; /* this will depend on parent containers width */
height:auto;
}
see demo here ( re-size browser width and height to see the change ) 在此处查看演示 ( 调整浏览器的宽度和高度以查看更改 )
By default Android maintain three folders for the images with different resolution reason behind it is the use or the resolution of the Android Device on which the application gonna execute. 默认情况下,Android为具有不同分辨率的图像维护三个文件夹,其背后是应用将在其上执行的Android设备的使用或分辨率。
hdpi image folder maintain images for the Android Broad Screen set or Android Phones with the Higher resolution. hdpi图像文件夹维护Android宽屏集或具有更高分辨率的Android手机的图像。
ldpi image folder for Lower images quality which supports by the earlier sets of the android ldpi图像文件夹,用于较低图像质量,由较早版本的android支持
mdpi image folder for medium images support mdpi图像文件夹,用于中等图像支持
xhdpi image folder for devices with maximum resolution. xhdpi图像文件夹,用于具有最大分辨率的设备。
xxhdpi image folder for devices extra large devices(Like Google Nexus 10 need to add a 144*144px icon in the drawable-xxhdpi or drawable-480dpi folder.) 用于大型设备的xxhdpi图像文件夹(例如Google Nexus 10需要在drawable-xxhdpi或drawable-480dpi文件夹中添加144 * 144px图标。)
Android OS select the image it self by checking the compatible device and its resolution. Android操作系统通过检查兼容设备及其分辨率来选择其自身的图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.