Example usage for android.view Display getSize

List of usage examples for android.view Display getSize

Introduction

In this page you can find the example usage for android.view Display getSize.

Prototype

public void getSize(Point outSize) 

Source Link

Document

Gets the size of the display, in pixels.

Usage

From source file:my.home.lehome.fragment.MessageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    mScreenWidth = size.x;// w ww .jav  a 2s.c o m
    mScreenHeight = size.y;

    View contentView = inflater.inflate(R.layout.fragment_send_message, container, false);
    setupViews(contentView);
    return contentView;
}

From source file:com.example.android.animationsdemo.BoardFragment.java

public void createCol() {
    int colNo = board.getColNo();
    Log.i("colNo", "colNo=" + colNo);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;
    Log.i("conditions", "codition start=" + Math.max(0, start) + "\n check = "
            + Math.min(start + MAX_COL_DISPLAYED, board.getColNo()) + "in createCOl");
    for (int i = Math.max(0, start); i < Math.min(start + MAX_COL_DISPLAYED, board.getColNo()); i++) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View columnView = inflater.inflate(R.layout.columns_layout, null, false);
        LinearLayout ll = (LinearLayout) columnView.findViewById(R.id.ll);
        ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT, 1.0f / MAX_COL_DISPLAYED));
        TextView tv = (TextView) columnView.findViewById(R.id.tv);
        tv.setText(board.getColName(i));
        Button addCard = (Button) columnView.findViewById(R.id.addCard);
        LinearLayout cardContainerLayout = (LinearLayout) columnView.findViewById(R.id.cardContainer);
        cardContainerLayout.setTag("col" + board.getColName(i));
        cardContainerLayout.setId(position);
        cardContainerLayout.setMinimumHeight(height);
        cardContainerLayout.setMinimumWidth(width / MAX_COL_DISPLAYED);
        Log.i("Drag", "Calling drag constructor ");
        cardContainerLayout.setOnDragListener(new MyDragListener(rootViewGroup));
        Log.i("Drag", "Drag Constructor Called ");
        addCard.setOnClickListener(new View.OnClickListener() {
            @Override//from   ww w. j a  v a  2s .  c  om
            public void onClick(View view) {
                BoardFragment.this.addItem(view);
            }
        });
        //cardContainerLayout.setLayoutTransition(new LayoutTransition());

        rootViewGroup.addView(columnView);
    }
}

From source file:io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.java

private void addDisplayInfo() throws IOException {
    Display display = UiAutomatorBridge.getInstance().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    serializer.attribute(NAMESPACE, "rotation", Integer.toString(display.getRotation()));
    serializer.attribute(NAMESPACE, "width", Integer.toString(size.x));
    serializer.attribute(NAMESPACE, "height", Integer.toString(size.y));
}

From source file:com.cypress.cysmart.CommonFragments.ProfileControlFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Getting the device name and address passed
    mDeviceNameProfile = getArguments().getString(ARG_DEVICE_NAME);
    mDeviceAddressProfile = getArguments().getString(ARG_DEVICE_ADDRESS);
    application = (CySmartApplication) getActivity().getApplication();

    // Getting the width of the device
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    width = size.x;// w w  w  .ja va  2 s  . c om

}

From source file:com.inductivebiblestudyapp.ui.dialogs.SimpleTooltipDialog.java

/**
 * Returns screen size in size 2 array.//from  w w  w .ja  v a2s  . c o  m
 * Taken directly from:
  * https://github.com/kvirair/Quick-Action/blob/master/src/garin/artemiy/quickaction/library/QuickAction.java
 * @param dimens 0 will become X size, 1 Y size.
 */
@SuppressWarnings("deprecation")
protected void getScreenDimens(int[] dimens) {
    if (dimens.length < 2) {
        throw new IllegalArgumentException("Cannot store result in length <2");
    }
    final int X = 0;
    final int Y = 1;

    WindowManager windowManager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Display display = windowManager.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        dimens[X] = size.x;
        dimens[Y] = size.y;
    } else {
        dimens[X] = windowManager.getDefaultDisplay().getWidth();
        dimens[Y] = windowManager.getDefaultDisplay().getHeight();
    }
}

From source file:com.cypress.cysmart.CommonFragments.ProfileControlFragment.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    // Getting the width on orientation changed
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;

    /**/* w ww  . j  a va 2 s. c o  m*/
     * Getting the orientation of the device. Set margin for pages as a
     * negative number, so a part of next and previous pages will be showed
     */
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        pager.setPageMargin(-width / 2);
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        pager.setPageMargin(-width / 3);
    }
    pager.refreshDrawableState();
}

From source file:com.orange.labs.sdk.RestUtils.java

public RestUtils(Context context) {
    // Create Volley Request Queue thanks to context
    mRequestQueue = Volley.newRequestQueue(context);

    // Fix maxWidth & maxHeight of screen
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    maxWidth = size.x;/* ww w.jav a 2s .  co m*/
    maxHeight = size.y;
}

From source file:org.telegram.ui.LoginActivity.java

public void setPage(int page, boolean animated, Bundle params, boolean back) {
    if (android.os.Build.VERSION.SDK_INT > 13) {
        Point displaySize = new Point();
        Display display = getWindowManager().getDefaultDisplay();
        display.getSize(displaySize);

        final SlideView outView = views[currentViewNum];
        final SlideView newView = views[page];
        currentViewNum = page;/* www. j  ava  2 s .co  m*/

        newView.setParams(params);
        getSupportActionBar().setTitle(newView.getHeaderName());
        newView.onShow();
        newView.setX(back ? -displaySize.x : displaySize.x);
        outView.animate().setInterpolator(new AccelerateDecelerateInterpolator())
                .setListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animator) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {
                        outView.setVisibility(View.GONE);
                        outView.setX(0);
                    }

                    @Override
                    public void onAnimationCancel(Animator animator) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animator) {
                    }
                }).setDuration(300).translationX(back ? displaySize.x : -displaySize.x).start();
        newView.animate().setInterpolator(new AccelerateDecelerateInterpolator())
                .setListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animator) {
                        newView.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {
                    }

                    @Override
                    public void onAnimationCancel(Animator animator) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animator) {
                    }
                }).setDuration(300).translationX(0).start();
    } else {
        views[currentViewNum].setVisibility(View.GONE);
        currentViewNum = page;
        views[page].setParams(params);
        views[page].setVisibility(View.VISIBLE);
        getSupportActionBar().setTitle(views[page].getHeaderName());
        views[page].onShow();
    }
}

From source file:com.pdftron.pdf.controls.PrintAnnotationsSummaryDialogFragment.java

@Override
public void onStart() {
    super.onStart();
    mDialogButton = mDialog.getButton(AlertDialog.BUTTON_POSITIVE);

    if (Utils.isTablet(getActivity())) {
        // a hack for shrinking the dialog's width
        final int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        Window window = mDialog.getWindow();
        View view = window.peekDecorView();
        if (view != null && Utils.isHoneycombMR2()) {
            view.measure(spec, spec);// ww  w.ja  v  a 2s . co m
            int width = 3 * view.getMeasuredWidth() / 2;

            Display display = getActivity().getWindowManager().getDefaultDisplay();
            Point size = new Point();
            display.getSize(size);
            int widthScreen = size.x;

            if (width < 2 * widthScreen / 3) {
                mDialog.getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT);
            }
        }
    }

    updateWidgets();
}

From source file:io.selendroid.server.model.internal.execute_native.IsElementDisplayedInViewport.java

@SuppressWarnings("deprecation")
public boolean isDisplayedOnViewport(View view) {
    int coordinates[] = { -1, -1 };
    int width = 0, height = 0;

    view.getLocationOnScreen(coordinates);
    if (coordinates[0] + view.getWidth() < 0)
        return false;
    if (coordinates[1] + view.getHeight() < 0)
        return false;

    if (width == 0 || height == 0) {
        if (instrumentation.getContext() == null)
            return false;
        Display display = ((WindowManager) instrumentation.getContext()
                .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        try {/*from   w w w  .ja  va 2  s . c o  m*/
            android.graphics.Point screenSize = new android.graphics.Point();
            display.getSize(screenSize);
            width = screenSize.x;
            height = screenSize.y;
        } catch (NoSuchMethodError e) {
            width = display.getWidth();
            height = display.getHeight();
        }
    }

    if (coordinates[0] > width)
        return false;
    if (coordinates[1] > height)
        return false;

    return true;
}