Change background color when displaying popup

I want to make the background darker when displayed PopupWindow. Just like a dolphin browser -

In front of the popup

Look at the background color before the PopupWindow is shown

After PopupWindow

And now see the background color after the PopupWindow is shown.

The background color is darker than it was. So how can we do this?

+5
source share
3 answers

In your XML file, add something like this with a width and height like "match_parent".

<RelativeLayout
        android:id="@+id/bac_dim_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#C0000000"
        android:visibility="gone" >
</RelativeLayout>

In your oncreate activities

//setting background dim when showing popup
back_dim_layout = (RelativeLayout) findViewById(R.id.bac_dim_layout);

Finally, make it visible when you show your popupwindow and make it visible when you exit popupwindow.

back_dim_layout.setVisibility(View.Visible);
back_dim_layout.setVisibility(View.GONE);
+3
source

If I'm not mistaken ... you can create an action with a list ... and put the topic in the dialog box in your manifest like this.

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

this will make the background darker ..

0

, - , . mystyle.xml .

<resources> 
   <style name="customStyle" parent="@android:style/Theme.Dialog">
     <item name="android:windowBackground">@android:color/transparent</item>
   </style>
</resources>

make this change in menifest.xml

<activity android:name="yourActivity" android:theme="@style/customStyle"></activity>
0
source

All Articles