title: How to android Popup Window match sreen size width
body: <p>I have implemented popup window in my Activity. Problem is that i want set width of popup window match screen size, Now i have space left on both sides. Here is how it looks  now <a href="https://i.stack.imgur.com/cAiP7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cAiP7.jpg" alt="Popup picture sample"></a></p>
  
  <p>Here is my popup code:</p>
  
  <pre><code>                    LayoutInflater inflater = (LayoutInflater) MainActivity.this
                              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                      //Inflate the view from a predefined XML layout
                      View layout = inflater.inflate(R.layout.activity_pop_up, null);
  
                      ImageView baner3img = (ImageView ) layout.findViewById(R.id.baner3img);
  
                      Picasso.with(MainActivity.this).load(hrefScroll.get(2))
                              .into(baner3img);
                      // create  PopupWindow
                      pw = new PopupWindow(layout, ViewPager.LayoutParams.MATCH_PARENT, ViewPager.LayoutParams.MATCH_PARENT,true);
  
                      ImageView close = (ImageView) layout.findViewById(R.id.close);
  
                      close.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
  
                              findViewById(R.id.relativeLayoutZaFragment).post(new Runnable() {
                                  public void run() {
                                      pw.dismiss();
                                  }
                              });
                          }
                      });
  
                      findViewById(R.id.relativeLayoutZaFragment).post(new Runnable() {
                          public void run() {
                              pw.setWindowLayoutMode(
                                     ViewGroup.LayoutParams.MATCH_PARENT,
                                     ViewGroup.LayoutParams.MATCH_PARENT);
                              pw.setHeight(1);
                              pw.setWidth(1);
                              pw.showAtLocation(findViewById(R.id.relativeLayoutZaFragment), Gravity.CENTER, 1, 1);
                              new Handler().postDelayed(new Runnable(){
                                  public void run() {
                                      pw.dismiss();
                                  }
                              }, 5 *1000);
                          }
                      });
                  }
              });
  </code></pre>
  
  <p>activity_pop_up.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/popup"
  android:layout_width="match_parent"
  
  android:layout_height="match_parent"
  tools:context="com.example.bolt.automagazin.PopUp"&gt;
  
  
  &lt;ImageView
      android:id="@+id/baner3img"
      android:layout_width="match_parent"
      android:layout_height="200dp"
      android:layout_alignParentStart="true"
      android:layout_centerVertical="true"
      app:srcCompat="@drawable/autojedan" /&gt;
  
  &lt;ImageView
      android:id="@+id/close"
      android:layout_width="50dp"
      android:layout_height="50dp"
      android:layout_alignParentEnd="true"
      android:layout_alignTop="@+id/baner3img"
      android:layout_marginEnd="15dp"
      android:visibility="visible"
      app:srcCompat="@drawable/closeee" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>