0

I am using a custom popup window. On Load I have to pass the height and width of the window. But I want to load the popup for all screensizes. I am using the below function to load my popup.

private void loadPopup() {
    LayoutInflater inflater = this.getLayoutInflater();
    final View layout = inflater.inflate(R.layout.activity_pop_up_ad, null);

    final PopupWindow windows = new PopupWindow(layout , 300,500,true);

    layout.post(new Runnable() {
        public void run() {
            windows.showAtLocation(layout,Gravity.CENTER, 0, 0);
        }

    });
    ImageButton close = (ImageButton) layout.findViewById(R.id.close);
       close.setOnClickListener(new OnClickListener() {

         @Override
         public void onClick(View v) {
             windows.dismiss();
         }
       });
}

I tried this one. But it completes the screen size. I don't want that much filled.

windows.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

Any ideas?

1 Answers1

0

Can't you just detect the screen height / width and then scale down by some factor so it does not fill the screen as much as you want?

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

The above code should get you your height and width of the screen and then you can just divide or subtract down the height and width to make the pop up fill as much of the screen as you want.

was this what you wanted? or did i misunderstand?

daredevil1234
  • 1,303
  • 1
  • 10
  • 34