I have an Activity A, and there is a button B in the view. If somebody presses B then I want a pop-up which can take some part of screen making the A invisible in that area but rest of A is visible but not active. How can I achieve this?
I have an Activity A, and there is a button B in the view. If somebody presses B then I want a pop-up which can take some part of screen making the A invisible in that area but rest of A is visible but not active. How can I achieve this?
if you are working with Material Design you should use @android:style/Theme.Material.Dialog.NoActionBar
You can do it programicly
Create Class MyDialog
import android.app.Activity;
import android.app.Dialog;
import android.view.Window;
import android.widget.TextView;
public class MyDialoge{
Activity activity;
TextView txt_Message;
Dialog dialog;
public ViewDialog(Activity activity) {
this.activity = activity;
}
public void showDialog(String message){
dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.custom_progress_dialog);
txt_Message = dialog.findViewById(R.id.txt_message);
txt_Message.setText(message);
//if you want to dimiss the dialog
//dialog.dimiss()
dialog.show();
}
public void dimiss(){
try {
dialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
}
After that crate the layout -> call it my_dialog
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Hello PopUp Message"/>
</RelativeLayout>
In your Activity
MyDialog myDialog = new MyDialog(MainActivity.this);
myDialog.showDialog("Say Hello to Me");
To dimiss
myDialog.dimiss();