Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- popup = new PopupWindow(context);
- popup.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
- popup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
- Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpSize, context.getResources().getDisplayMetrics()));
- View popup = LayoutInflator.inflate(int resId);
- if(popup != null) {
- // set up an observer that will be called once the listView's layout is ready
- android.view.ViewTreeObserver viewTreeObserver = listView.getViewTreeObserver();
- if (viewTreeObserver.isAlive()) {
- viewTreeObserver.addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- // This will be called once the layout is finished, prior to displaying.
- View popup = findViewById(resId);
- if(popup != null) {
- int width = popup.getMeasuredWidth();
- int height = popup.getMeasuredHeight();
- // don't need the listener any more
- popup.getViewTreeObserver().removeGlobalOnLayoutListener(this);
- }
- }
- });
- }
- }
- Display display = getWindowManager().getDefaultDisplay();
- Log.e("", "" + display.getHeight() + " " + display.getWidth());
Add Comment
Please, Sign In to add comment