Search code examples
androidandroid-popupwindow

open activity as popupwindow with transparent background


Helloo

I have simple question about popupwindow.

If click on button i want open activity as popupwindow with numberpicker . Values in numberpicker i need pass from activity. How to achieve pass values i think i should extend PopupWindow class and create custom PopupWindow or is another solutiion. Thank the cose is as follow

   ViewGroup parent = (ViewGroup) view.getParent();
    final View v = getLayoutInflater().inflate(R.layout.activity_duration, parent, false);
    np = (NumberPicker)findViewById(R.id.durationPicker);
    popupWindowDuration = new PopupWindow(v, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
    popupWindowDuration.showAtLocation(findViewById(R.id.main_content), Gravity.CENTER, 0, 0); here

Already set at manifest

 <activity android:theme="@android:style/Theme.Dialog">

And second is how to set background transparent . Becase this code hide previous popupwindows.


Solution

  • Set following code in your second activity's onCreate method below setContentView

    getWindow().getDecorView().setBackground(new ColorDrawable(Color.TRANSPARENT));