开发者

How do you tell Android not to scale images?

开发者 https://www.devze.com 2023-04-03 08:30 出处:网络
I have some pictures in the /drawable folder, which to my understanding is intepreted as /drawable-mdpi. Now these images are scaled when being used (depending on the device). I don\'t want to add mor

I have some pictures in the /drawable folder, which to my understanding is intepreted as /drawable-mdpi. Now these images are scaled when being used (depending on the device). I don't want to add more pictures, because they don't exist. And I don't have the resources to create different res pictures.

I just want the pictures to appear smaller on bigger devices. Is there a way of not scaling the images?

I'd hate to have to hard-code all the picture sizes.

This is the second question, as edits aren't attractin开发者_StackOverflow社区g attention at all. Sorry about that.


Adding the BitmapFactory.Options parameter to the decodeResource with the flag inScaled set to false is how to do it

BitmapFactory.Options mNoScale = new BitmapFactory.Options();
mNoScale.inScaled = false;
BitmapFactory.decodeResource(getResources(), R.drawable.id, mNoScale);


What happens when you say layout_width="wrap_content" layout_height="wrap_content"?

0

精彩评论

暂无评论...
验证码 换一张
取 消