Мне нужно иметь доступ для клика по моему фрагменту (например, по нажатию кнопки), когда отображается DialogFragment.
Но когда я нажму за пределами DialogFragment, это будет отклонено.
Используемый код для отображения DialogFragment :
FragmentManager fragmentManager = getFragmentManager();
MyDialogMapFragment dialogFragment = new MyDialogMapFragment();
dialogFragment.show( fragmentManager, "" );
MyDialogMapFragment Класс:
public class MyDialogMapFragment extends DialogFragment {
private Activity mActivity;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.dialog_map_info, container, false);
return rootView;
}
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(getActivity(), R.style.DialogMap);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_map_info);
dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
lp.gravity = Gravity.BOTTOM;
dialog.getWindow().setAttributes(lp);
return dialog;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof Activity) {
mActivity = (Activity) context;
}
}
}
dialog_map_info.xml Макет:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="90dp"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<RelativeLayout
android:id="@+id/mainFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:clickable="true"
android:focusable="true"
android:background="@drawable/background_map_info">
<ProgressBar
android:id="@+id/progress_loader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerInParent="true"
style="?android:attr/progressBarStyle" />
<TextView
android:id="@+id/itemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Test" />
</RelativeLayout>
</FrameLayout>
Ниже изображение опишет, каков мой макет:
![Sample of my layout](https://i.stack.imgur.com/J8WVw.jpg)