开发者

Disabling background image shrinking in Android

开发者 https://www.devze.com 2023-01-18 12:44 出处:网络
It seems background 开发者_开发百科images are automatically shrunk in Android, for example, I use setBackgroundDrawable to set background of a view:

It seems background 开发者_开发百科images are automatically shrunk in Android, for example, I use setBackgroundDrawable to set background of a view:

Drawable background = getBackground();
myView.setBackgroundDrawable(background);

Instead of shrinking, I want the image to be cropped to fit the screen size. How to do it? Thanks.


Finally I fixed this problem. I use BitmapDrawable instead of Drawable, since BitmapDrawable has method setGravity(int) which can set the gravity to position/stretch the object.

0

精彩评论

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