这是我正在尝试的:
...BitmapFactory.Options resizeOptions = new BitmapFactory.Options();resizeOptions.inSampleSize = 3; // decrease size 3 timesresizeOptions.inScaled = true;options = new displayImageOptions.Builder().showStubImage(R.drawable.blank).showImageForEmptyUri(R.drawable.no_image).cacheInMemory().cacheOndisc().deCodingOptions(resizeOptions).build();...
由于某种原因,此代码不会使图像缩小3倍.
有人有更好的方法来按照指定的密度调整图像大小吗?
解决方法 认真阅读Java文档:
Options.inSampleSize
of incoming options will NOT be consIDered. library calculate the most appropriate sample size itself according toimageScaleType(...)
options.
另请查看定义图像目标大小的ImageSizeUtil.defineTargetSizeforVIEw(ImageVIEw imageVIEw,int maxImageWIDth,int maxImageHeight):
Size is defined by target vIEw parameters,configuration parameters or device display dimensions.
Get the actual drawn
Size computing algorithm:getWIDth()
andgetHeight()
of the VIEw. If vIEw haven’t drawn yet then go to step #2. Getlayout_wIDth
andlayout_height
. If both of them haven’t exact value then go to step #3. GetmaxWIDth
andmaxHeight
. If both of them are not set then go to step #4. GetmaxImageWIDth
param (maxImageWIDthForMemoryCache) andmaxImageHeight
param (maxImageHeightForMemoryCache). If both of them are not set (equal 0) then go to step #5. Get device screen dimensions.
UIL根据imageScaleType和targetSize(以及ImageVIEw的scaleType)定义结果位图大小.
总结以上是内存溢出为你收集整理的如何在使用Android Universal Image Loader的视图中显示之前调整图片大小?全部内容,希望文章能够帮你解决如何在使用Android Universal Image Loader的视图中显示之前调整图片大小?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)