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

display getSize()

时间:2015-01-13 19:27:40      阅读:196      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!