Display getSize - top ranked examples from Open Source projects

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

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:set, getSize
	} 
 
	@SuppressWarnings("deprecation") 
	@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
	public static Point getSize(Context context){
		Point size = new Point();
		WindowManager w = ((Activity)context).getWindowManager();
 
		if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2){
			w.getDefaultDisplay().getSize(size);
		}else{ 
			Display d = w.getDefaultDisplay(); 
			size.set(d.getWidth(), d.getHeight());
		} 
		size.set(size.x, size.y-getStatusBarHeight(context));
		return size;
	} 
 
	@SuppressWarnings("deprecation") 
	@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
6
CodeRank
This code example shows how to use the following methods:getSize
	} 
 
	public static int sWidth = -1;
	public static int getScreenWidth(Activity a) {
		if(sWidth == -1){
			Point outSize = new Point();
			a.getWindowManager().getDefaultDisplay().getSize(outSize);
			sWidth = outSize.x;
		} 
		 
		return sWidth;
	} 
	 
} 
6
CodeRank
This code example shows how to use the following methods:getSize
	} 
 
	@TargetApi(13) 
	void GetScreenSizeHC(Point size) {
        WindowManager w = getWindowManager();
		w.getDefaultDisplay().getSize(size);
	} 
	 
	void GetScreenSize(Point size) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			GetScreenSizeHC(size);
		} else { 
	        WindowManager w = getWindowManager();
	        Display d = w.getDefaultDisplay();
			size.x = d.getWidth();
			size.y = d.getHeight();
		} 
	} 
	 
	public void Initialize() { 

6
CodeRank
This code example shows how to use the following methods:getHeight, getSize, getWidth
	private View _dialogView;
	 
	private static Point getDisplaySize(final Display display) {
	    final Point point = new Point();
	    try { 
	        display.getSize(point);
	    } catch (java.lang.NoSuchMethodError ignore) { // Older device
	        point.x = display.getWidth();
	        point.y = display.getHeight();
	    } 
	    return point;
	} 
	 
	public SimplePopup(int target_layout, View parent_view)
	{ 
		_parent_view = parent_view;
		Context context = parent_view.getContext();
		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		Display display = wm.getDefaultDisplay();
		Point size = getDisplaySize(display);
6
CodeRank
This code example shows how to use the following methods:getSize
	 
	int getDisplayWidth() { 
		WindowManager windowManager = getWindowManager();
		Display display = windowManager.getDefaultDisplay();
		Point size = new Point();
		display.getSize(size);
		return size.x;
	} 
	 
	int getDisplayHeight() { 
		WindowManager windowManager = getWindowManager();
		Display display = windowManager.getDefaultDisplay();
		Point size = new Point();
		display.getSize(size);
		return size.y;
	} 
	 
	void setResolutionLabels() { 
		Runnable myRunnable = new Runnable() {
			public void run() 
5
CodeRank
This code example shows how to use the following methods:getSize
		 
		return "unknown"; 
	} 
	 
	public static int GetDeviceWidth(Context context) {
		Point windowSize = new Point();
		WindowManager manager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
		manager.getDefaultDisplay().getSize(windowSize);
		 
		return windowSize.x;
	} 
	 
	public static String GetTrimmedText(String text, int maxTextLength) {
		if(text.length() < maxTextLength || maxTextLength <= 3) {
			return text;
		} 
		 
		String prefix = text.substring(0, maxTextLength / 2);
		String postfix = text.substring(text.length() - (maxTextLength / 2 + 3));
		 
6
CodeRank
This code example shows how to use the following methods:getSize
	{ 
	  int[] displaySize = {0, 0};
 
    WindowManager w = getWindowManager();
    if (Build.VERSION.SDK_INT >= 13) {
      Point size = new Point();
      w.getDefaultDisplay().getSize(size);
      displaySize[0] = size.x;
      displaySize[1] = size.y;
    } else { 
      Display d = w.getDefaultDisplay();
      displaySize[0] = d.getWidth();
      displaySize[1] = d.getHeight();
    } 
     
    return displaySize;
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getHeight, getSize, getWidth
This code example shows how to use the following methods:getSize
	WindowManager w;
 
	public DisplayUtil(Context context) {
		mContext = (Activity) context;
		w = mContext.getWindowManager();
		size = new Point();
		getSize(); 
	} 
 
	public Point getSize() {
 
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			w.getDefaultDisplay().getSize(size);
			Measuredwidth = size.x;
			Measuredheight = size.y;
		} else { 
			Display d = w.getDefaultDisplay();
			Measuredwidth = d.getWidth();
			Measuredheight = d.getHeight();
		} 
6
CodeRank

Related Display getSize Questions & Answers:

getSize Method Overview
Gets the size of the display, in pixels.
See Code Examples for other Android Display Methods: