This is not a duplicate question. If it was, I wouldn't ask it. The solution to the supposed duplicate question did not work. So this is not a duplicate question.
I have a fullscreen translucent DialogFragment (a loader fragment) shown over an activity. The activity behind is still receiving touch events. How do you disallow the activity from receiving touch events? I've already set the root layout of DialogFragment to clickable="true", but the activity is still receiving touch events.
Please help.
My DialogFragment code:
public static LoaderDialogFragment newInstance() {
LoaderDialogFragment df = new LoaderDialogFragment();
df.setCancelable(false);
return df;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_FRAME | STYLE_NO_TITLE, R.style.AppTheme_LoaderDialog);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
Window w = getDialog().getWindow();
if(w != null) {
w.setBackgroundDrawable(new ColorDrawable(Color.parseColor(TRANSLUCENT_COLOR)));
w.setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
}
return inflater.inflate(R.layout.fragment_loader_dialog, container, false);
}
and layout file:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loader_dialog_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>