Android Display - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Display class.

This code example shows how to use the following methods:getDisplayId, getHeight, getMetrics, getOrientation, getPixelFormat
        return result.toString();
    } 
 
    private static Object collectDisplayData(Display display) {
        final DisplayMetrics metrics = new DisplayMetrics();
        display.getMetrics(metrics);
 
        final StringBuilder result = new StringBuilder();
 
        result.append(collectCurrentSizeRange(display));
        result.append(collectFlags(display));
        result.append(display.getDisplayId()).append(".height=").append(display.getHeight()).append('\n');
        result.append(collectMetrics(display, "getMetrics"));
        result.append(collectName(display));
        result.append(display.getDisplayId()).append(".orientation=").append(display.getOrientation()).append('\n');
        result.append(display.getDisplayId()).append(".pixelFormat=").append(display.getPixelFormat()).append('\n');
        result.append(collectMetrics(display, "getRealMetrics"));
        result.append(collectSize(display, "getRealSize"));
        result.append(collectRectSize(display));
        result.append(display.getDisplayId()).append(".refreshRate=").append(display.getRefreshRate()).append('\n');

9
CodeRank
This code example shows how to use the following methods:getSize
        return getDisplaySize().x;
    } 
 
    @Override 
    public Point getDisplaySize() {
        Point dimensions = new Point();
        ((WindowManager) CgeoApplication.getInstance().getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay().getSize(dimensions);
        return dimensions;
    } 
 
} 
8
CodeRank
This code example shows how to use the following methods:getMetrics
	 */ 
	public TapjoyDisplayMetricsUtil(Context theContext)
	{ 
		context = theContext;
		 
		metrics = new DisplayMetrics();
		WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
		windowManager.getDefaultDisplay().getMetrics(metrics);
		 
		configuration = context.getResources().getConfiguration();
	} 
	 
	 
	/** 
	 * Gets the screen density. 
	 * @return								Screen density in DPI. 
	 */ 
	public int getScreenDensity() 
	{ 
		return metrics.densityDpi;
8
CodeRank
This code example shows how to use the following methods:getMetrics
	 * @return The corresponding display pixel value. 
	 */ 
	public int toDisplayPixels(float densityIndependentPixels)
	{ 
		// Get display metrics. 
		DisplayMetrics metrics = new DisplayMetrics();
		mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
		 
		// Return the actual pixel value calculated from the density. 
		return (int) (densityIndependentPixels * metrics.density);
	} 
} 
8
CodeRank
This code example shows how to use the following methods:getHeight, getWidth
	 
	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);
		SLIDE_MAX_DISTANCE_Y = 120;
		//orientation = context.getResources().getConfiguration().orientation; 
	} 
	 
	@Override 
	public boolean onDown(MotionEvent e) {
		return false; 
	} 
 
	@Override 
7
CodeRank
This code example shows how to use the following methods:getHeight
    } 
 
    @Override 
    public Point getDisplaySize() {
        final Display display = getDisplay();
        return new Point(display.getWidth(), display.getHeight());
    } 
 
    private static Display getDisplay() {
        return ((WindowManager) CgeoApplication.getInstance().getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getMetrics
			//enableZoning(usingSmallScreen()); 
		} 
 
		@Override 
		protected void getDPI(float[] values) {
			DisplayMetrics metrics = new DisplayMetrics();
			getWindowManager().getDefaultDisplay().getMetrics(metrics);
 
			values[0] = metrics.xdpi;
			values[1] = metrics.ydpi;
		} 
 
		@Override 
		protected void displayMessageOnOSD(String msg) {
			Log.i(LOG_TAG, "OSD: " + msg);
			Toast.makeText(ScummVMActivity.this, msg, Toast.LENGTH_LONG).show();
		} 
 
		@Override 
		protected void setWindowCaption(final String caption) {
8
CodeRank
This code example shows how to use the following methods:getMetrics
	{ 
		if (metrics == null) {
			WindowManager windowManager = (WindowManager) parent.getContext().getSystemService(Context.WINDOW_SERVICE);
			Display display = windowManager.getDefaultDisplay();
			metrics = new DisplayMetrics();
			display.getMetrics(metrics);
		} 
		return metrics;
	} 
 
	protected double getScaledPixels(View parent)
	{ 
		DisplayMetrics metrics = getDisplayMetrics(parent);
		if (units == TypedValue.COMPLEX_UNIT_DIP) {
			return (metrics.density * this.value);
		} else if (units == TypedValue.COMPLEX_UNIT_SP) {
			return (metrics.scaledDensity * this.value);
		} 
		return -1; 
	} 
7
CodeRank
This code example shows how to use the following methods:getHeight, getWidth
 
	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,
7
CodeRank
This code example shows how to use the following methods:getDisplayId
      if (route.isEnabled() && display != null) {
        if (preso == null) {
          showPreso(route);
          Log.d(getClass().getSimpleName(), "enabled route");
        } 
        else if (preso.getDisplay().getDisplayId() != display.getDisplayId()) {
          clearPreso(true); 
          showPreso(route);
          Log.d(getClass().getSimpleName(), "switched route");
        } 
        else { 
          // no-op: should already be set 
        } 
      } 
      else { 
        clearPreso(true); 
        Log.d(getClass().getSimpleName(), "disabled route");
      } 
    } 
  } 
7
CodeRank

Related Android Display Questions & Answers:

See Code Examples for Android Display Methods: