首页 > 其他 > 详细

display getSize()

时间:2015-01-13 19:27:14      阅读:216      评论:0      收藏:0      [点我收藏+]

If you want the the display dimensions in pixels you can use getSize: 

Display display = getWindowManager().getDefaultDisplay(); 
Point size = new Point(); 
display.getSize(size); 
int width = size.x; 
int height = size.y; 

If you‘re not in an Activity you can get the default Display via WINDOW_SERVICE: 

WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); 
Display display = wm.getDefaultDisplay(); 

Before getSize was introduced (in API level 13), you could use the getWidth and getHeight methods that are now deprecated: 

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();  // deprecated 
int height = display.getHeight();  // deprecated

display getSize()

原文:http://www.cnblogs.com/mumue/p/4222253.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!