Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change background color when a Popup is shown

I want to make the background darker when a PopupWindow is shown. Just like Dolphin Browser does like-

Before the PopupWindow

Look at the background color before the PopupWindow is shown

After the PopupWindow

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

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

like image 685
Rajkiran Avatar asked May 10 '12 10:05

Rajkiran


1 Answers

In your xml file add something like this with width and height as '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 activity oncreate

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

Finally make visible when you show your popupwindow and make its visible gone when you exit popupwindow.

back_dim_layout.setVisibility(View.Visible);
back_dim_layout.setVisibility(View.GONE);
like image 89
user2257590 Avatar answered Sep 30 '22 06:09

user2257590