We’re not going to use ViewOverlay here. We’ll use Dialog instead. The overlay does not show on button click. What I did was let the overlay appear when the activity is loaded. First, create the XML file for the contents of that dialog overlay. \app\src\main\res\layout\popup_content.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="#78000000" android:padding="@dimen/activity_margin" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:textColor="#ffffff" android:text="This is your dialog with transparent background." android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/btn_close_overlay" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/colorPrimary" android:textColor="#ffffff" android:text="Dismiss"/> </LinearLayout> |
Then add the following code into your activity’s Java […]