title: Android PopupWindow - how to get same bottom margin for devices with on-screen buttons
body: <p>I have some issue with bottom margin on different devices.
  How to get same bottom margin for devices with/without on-screen buttons?</p>
  
  <p>Implementation of PopupWindow:</p>
  
  <pre><code>DisplayMetrics dm = new DisplayMetrics();
          activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
  
          int width = dm.widthPixels;
          int height = dm.heightPixels;
  
          View viewGroup= activity.getLayoutInflater().inflate(R.layout.my_dialog, null, false);
  
          popupWindow = new PopupWindow(viewGroup, width, height);
  </code></pre>
  
  <p>Nexus 6</p>
  
  <p><a href="https://i.stack.imgur.com/DKc07.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DKc07.png" alt="enter image description here"></a></p>
  
  <p>Samsung 5</p>
  
  <p><a href="https://i.stack.imgur.com/vPWkz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vPWkz.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#AA000000"
      &gt;
  
  
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_margin="15dp"
          android:background="#fff"
          android:layout_weight="1"&gt;
  
          ...
  
  
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>