开发者

How to specify the image's size for the left-image of a button?

I would like to put an image on a Button with some text, like:

--------------
[image] [text]
--------------

We can do this with Button, and specify the left Drawable, but it uses the "intrinsic" size of the drawable. If I understand correctly, this won't work across different density devices. If my image is 32x32 pixels, it will look really small on hdpi devices. Is there any way to specify the width and height of the draw开发者_如何学编程able, in dp, so that it will take the same amount of space on different devices?


This is correct. You need an hdpi, mdpi and ldpi version of the image and you just place them in the appropriate drawable folder and the OS will take care of the rest.

Here is a link to the resource scheme in case you need more info.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜