Browse » Home » Resource, Tips » Blog article: 获得当前Screen尺寸和Orientation mode

通过什么方式才能简单的得到当前Screen的尺寸和Orientation方向模式呢?
应用Android.view.displayWindowManager两个方法来完成题目中所提到的目的,以下是具体的代码:

/* First, get the Display from the WindowManager */
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();  

/* Now we can retrieve all display-related infos */
int width = display.getWidth();
int height = display.getHeight();
int orientation = display.getOrientation();

[Via Android Snippets]

Tags: ,

Posted in Resource, Tips |

Related Posts



Leave a Reply

You must be logged in to post a comment.