Android: Showing wrong screen resolution

前端 未结 6 1028
说谎
说谎 2020-11-29 10:19

I was trying to get the screen resolution of android phones,using this code

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDi         


        
6条回答
  •  粉色の甜心
    2020-11-29 10:50

    This seems to be working..though i dont know if its a right method..

    DisplayMetrics dm = new DisplayMetrics(); 
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    
    density=dm.densityDpi; 
    width=(density/160)*dm.widthPixels; 
    height=(density/160)*dm.heightPixels;
    

提交回复
热议问题