简体   繁体   English

Android按比例缩小图像

[英]Android Scaling down Images

i have some large resolution images that I need to scale to fit every screen as a background, the images are size of 1800x2880 and I need them to scale down to every screeen without any stretching(they are illustrations). 我有一些高分辨率图像,需要缩放以适合每个屏幕作为背景,图像尺寸为1800x2880,并且我需要将它们缩放到每个屏幕,而无需任何拉伸(它们是插图)。 What is the best approach? 最好的方法是什么?

The best approach is to read the android developer guide regarding supporting multiple screen sizes and do exactly as they say there. 最好的方法是阅读有关支持多种屏幕尺寸的android开发人员指南,并按照他们在此处所说的做。

Anything else someone might answer you here will be simplification or copy or re-written with his own words of what said there. 有人在这里回答您的其他任何事情都会被简化或用他自己的话语复制或重写。

edit: 编辑:

regarding stretching the images you have two possible approaches: 关于拉伸图像,您有两种可能的方法:

  • create a 9-patch with your background so it can fill-in the last pixel (or fill in key areas of the image that can/should be filled in without changing the general aspect of it (it will depends on the content of the image) 创建一个具有背景的9色块 ,以便可以填充最后一个像素(或填充可以/应该填充的图像关键区域,而无需更改其一般外观(这取决于图像的内容) )
  • mark the imageView to use CENTER_INSIDE CENTER_INSIDE标记为使用CENTER_INSIDE

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding). 统一缩放图像(保持图像的纵横比),以使图像的两个尺寸(宽度和高度)都等于或小于视图的相应尺寸(减去填充)。

在xhdpi文件夹上设置的图像。在XML中,您将使用fillparent。它将不会拉伸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM