Is it safe to use .getWidth on Display even though its deprecated

后端 未结 3 1694
挽巷
挽巷 2020-12-23 16:13

So i have a small problem, i\'m writing a function which need to send screen width to server. I got it all to work, and i use:

Display display = getWindowMan         


        
3条回答
  •  醉梦人生
    2020-12-23 16:35

    May be this approach will be helpful:

    DisplayMetrics displaymetrics = new DisplayMetrics();
    mContext.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int screenWidth = displaymetrics.widthPixels;
    int screenHeight = displaymetrics.heightPixels;
    

提交回复
热议问题