How do you tell Android not to scale images?

2019-02-19 11:24发布

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 attracting attention at all. Sorry about that.

2条回答
姐就是有狂的资本
2楼-- · 2019-02-19 11:37

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);
查看更多
对你真心纯属浪费
3楼-- · 2019-02-19 11:51

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

查看更多
登录 后发表回答