码迷,mamicode.com
首页 > 其他好文 > 详细

Display中getHeight()和getWidth() 官方废弃

时间:2014-06-03 11:37:47      阅读:395      评论:0      收藏:0      [点我收藏+]

标签:android   c   style   class   blog   code   

        今天使用Display获取屏幕的宽和高时出现下面的提示:

Display dp=getWindowManager().getDefaultDisplay();
        int Height=dp.getHeight();  ---->The method getHeight() from the type Display is deprecated
        int Width=dp.getWidth();    ---->The method getWidth() from the type Display is deprecated
bubuko.com,布布扣
官方解释:
int
getHeight() This method was deprecated in API level 13. Use getSize(Point) instead. int getWidth() This method was deprecated in API level 13. Use getSize(Point) instead. http://developer.android.com/reference/android/view/Display.html
bubuko.com,布布扣
bubuko.com,布布扣
替代的方法:
DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); SCREEN_WIDTH = dm.widthPixels; SCREEN_HEIGHT = dm.heightPixels;

解析heightPixels和widthPixels:
public int     heightPixels     The absolute height of the display in pixels.
public int     widthPixels     The absolute width of the display in pixels.
bubuko.com,布布扣

 

 

 

 

Display中getHeight()和getWidth() 官方废弃,布布扣,bubuko.com

Display中getHeight()和getWidth() 官方废弃

标签:android   c   style   class   blog   code   

原文地址:http://www.cnblogs.com/lyyh-victory/p/3760014.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!