title: How to restore the popup window's position when changes the orientation in android?
body: <p>I am trying to show popup windows wherever user touchs the screen. I am able to display popup windows at desired location. But problem is when popup window is in portrait mode if i changes the orientation in landscape mode that popup window is displaying in same position , because of that popup window is overlapping with views in landscape mode and same problem occurs when we change orientation landscape to portrait . My requirements are below
  1. Dont want to dismiss popup window when changes the orientation.
  2. change the positions of the all popup windows dynamically, whenever orientation changes so that views are not overlapped(popup window doesnt overlaps with image). Example when i change the orientation portrait to landscape popup windows position will move to bit upwards.</p>
  
  <pre><code>private void showPopup(final Activity context, Point p) {
      int popupWidth = 200;
      int popupHeight = 150;
      boolean showEditText = true;
      // Inflate the popup_layout.xml
      LinearLayout viewGroup = (LinearLayout) context
              .findViewById(R.id.popup);
      LayoutInflater layoutInflater = (LayoutInflater) context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View layout = layoutInflater.inflate(R.layout.popup_layout, viewGroup);
  
      // Creating the PopupWindow
      final PopupWindow popup = new PopupWindow(context);
      popup.setContentView(layout);
      popup.setWidth(popupWidth);
      popup.setHeight(popupHeight);
      popup.setFocusable(false);
      popup.setOutsideTouchable(false);
  
      // Some offset to align the popup a bit to the right, and a bit down,
      // relative to button's position.
      int OFFSET_X = 5;
      int OFFSET_Y = 5;
  
      // Clear the default translucent background
      popup.setBackgroundDrawable(new BitmapDrawable());
  
      // Displaying the popup at the specified location, + offsets.
      popup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + OFFSET_X, p.y
              + OFFSET_Y);
  
      final Button addname = (Button) layout.findViewById(R.id.addName);
  
  }
  </code></pre>