简体   繁体   English

根据设备屏幕调整图像的高度和宽度

[英]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.

相关问题 调整图像大小以填充屏幕宽度 - Resizing image to fill width of screen 如何根据Android中的设备密度和屏幕尺寸获取ImageView的最大宽度和最大高度 - How to get max-width and max-Height for ImageView According to device density and screen size in Android 如何获取设备原始宽度和高度或实际屏幕宽度和高度? - How to get device raw width and height or actual screen width and height ? Android根据宽度设置图像视图高度 - Android set image view height according to width 使用 ContraintLayout 根据屏幕高度调整两个等宽的 ImageView 的高度 - Adjust height of two ImageView with equal width according to screen height with ContraintLayout 与屏幕宽度和图像高度匹配的可点击图像 - Clickable image that matches screen width and image height 如何在Android中根据设备dpi设置与宽度成比例的高度 - How to set height proportional to width according to device dpi in android 如何裁剪图像的高度作为设备的高度-宽度? - How to crop image of size as the height - width of device? 将远程图像缩放到设备的高度和宽度 - Scale remote image to device height and width 如何根据视频的高度和宽度设置屏幕方向 - How to set screen orientation according to a video's height and width
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM