Code example for Display

Methods: getMetrics

0
	public Dimension(Context context)
	{ 
		mDM = new DisplayMetrics();
		WindowManager window = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); 
	    Display display = window.getDefaultDisplay();
	    display.getMetrics(mDM);
	     
		mRatioWidth = (float)getScreenWidth() / 480.0f;
		mRatioHeight = (float)getScreenHeight() / 800.0f;
	} 
	 
	/** 
	 * Sets the ratio for the conversion based on the screen width/height 
	 * @param width The width of the desired ratio 
	 * @param height The height of the desired ratio 
	 */ 
	public void setRatio(int width, int height)
	{ 
		mRatioWidth = (float)getScreenWidth() / width;
		mRatioHeight = (float)getScreenHeight() / height;
	}