Android scaling of images to screen density

前端 未结 3 1997
执念已碎
执念已碎 2020-12-05 08:18

I have an application with an embedded drawable 48x48 pixel at 71,12 pixels/inch I load the same image via a stream to a webserver, then load that stream

re         


        
3条回答
  •  星月不相逢
    2020-12-05 08:58

    Get the current density of the screen and set the drawable to that density

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int density  =  metrics.densityDpi
    myDrawable.setDensity(densityDpi);
    

提交回复
热议问题