[英]BitmapDrawable does not respect scaleType on view
I want to display an image synchronously on a view, and I am using Universal Image Loader: 我想在视图上同步显示图像,并且正在使用Universal Image Loader:
https://github.com/nostra13/Android-Universal-Image-Loader https://github.com/nostra13/Android-Universal-Image-Loader
On async call the library displays the image properly. 在异步调用中,库将正确显示图像。 Though, doing something like this: 虽然,做这样的事情:
myImageView.setBackground(new BitmapDrawable(getApplicationContext().getResources(), ImageLoader.getInstance().loadImageSync("path/to/image")));
The image gets displayed, ignoring my scaleType on layout, which is centerCrop. 图像被显示,而忽略了我在scaleCrop布局上的scaleType。 I want to do this without having to process the image which would increase the load time. 我想这样做而不必处理图像,这会增加加载时间。 I have been searching Google for 4 hours now without luck. 我已经搜索Google四个小时了,没有运气。 I landed on some threads in here but they are not helpful. 我在这里找到了一些线程,但是它们没有帮助。
Thank you for your time. 感谢您的时间。
You should use setImageDrawable()
instead of setBackground()
. 您应该使用setImageDrawable()
而不是setBackground()
。 Using the image as a background will always ignore the scale type. 将图像用作背景将始终忽略比例类型。
myImageView.setImageDrawable(new BitmapDrawable(getApplicationContext().getResources(), ImageLoader.getInstance().loadImageSync("path/to/image")));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.