resize image in android drawable

前端 未结 2 1897
北荒
北荒 2020-12-20 07:11

I have full resolution images in drawable folder need to resize according to phone screen size how to do that ?

2条回答
  •  情书的邮戳
    2020-12-20 08:08

    to get the width you should do this :

    Display display = getWindowManager().getDefaultDisplay();
    double deviceWidth;
    if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB_MR1)
                deviceWidth= display.getWidth();
            else {
                display.getSize(size);
                deviceWidth=size.x;
            }
    

提交回复
热议问题