Code example for Display

Methods: getHeight, getWidth

0
 
	private void initEnv(Context context) {
		// 获得屏幕大小 
		WindowManager windowManager = ((Activity)context).getWindowManager();
		Display display = windowManager.getDefaultDisplay();
		DISPLAY_WINDOW_WIDTH = display.getWidth();
		DISPLAY_WINDOW_HEIGHT = display.getHeight();
 
		SLIDE_MIN_DISTANCE_X = (int)(DISPLAY_WINDOW_WIDTH * FACTOR_PORTRAIT);
		SLIDE_MAX_DISTANCE_Y = (int)(DISPLAY_WINDOW_HEIGHT * FACTOR_LANDSCAPE);
		//orientation = context.getResources().getConfiguration().orientation; 
	} 
 
	@Override 
	public boolean onDown(MotionEvent e) {
		return false; 
	} 
 
	@Override 
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
			float velocityY) {