Guest User

Untitled

a guest
Dec 10th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. popup = new PopupWindow(context);
  2. popup.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
  3. popup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
  4.  
  5. Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpSize, context.getResources().getDisplayMetrics()));
  6.  
  7. View popup = LayoutInflator.inflate(int resId);
  8. if(popup != null) {
  9.  
  10. // set up an observer that will be called once the listView's layout is ready
  11. android.view.ViewTreeObserver viewTreeObserver = listView.getViewTreeObserver();
  12. if (viewTreeObserver.isAlive()) {
  13.  
  14. viewTreeObserver.addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() {
  15.  
  16. @Override
  17. public void onGlobalLayout() {
  18.  
  19. // This will be called once the layout is finished, prior to displaying.
  20.  
  21. View popup = findViewById(resId);
  22.  
  23. if(popup != null) {
  24. int width = popup.getMeasuredWidth();
  25. int height = popup.getMeasuredHeight();
  26.  
  27. // don't need the listener any more
  28. popup.getViewTreeObserver().removeGlobalOnLayoutListener(this);
  29. }
  30. }
  31. });
  32. }
  33. }
  34.  
  35. Display display = getWindowManager().getDefaultDisplay();
  36. Log.e("", "" + display.getHeight() + " " + display.getWidth());
Add Comment
Please, Sign In to add comment