Skip to content

Instantly share code, notes, and snippets.

@koocbor
Last active June 20, 2022 15:50
Show Gist options
  • Save koocbor/88db64192638bff09aa4 to your computer and use it in GitHub Desktop.
Save koocbor/88db64192638bff09aa4 to your computer and use it in GitHub Desktop.
Full Screen Dialog in Android
FullScreenDialog dialog = new FullScreenDialog();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
dialog.show(ft, FullScreenDialog.TAG);
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- Content here -->
</RelativeLayout>
public class FullScreenDialog extends DialogFragment {
public static final String TAG = "FullScreenDialog";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, R.style.FullScreenDialog);
}
@Override
public void onStart() {
super.onStart();
Dialog dialog = getDialog();
if (dialog != null) {
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
dialog.getWindow().setLayout(width, height);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle state) {
super.onCreateView(inflater, parent, state);
View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_layout, parent, false);
return view;
}
}
<style name="FullScreenDialogStyle" parent="android:theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowIsFloating">false</item>
</style>
@xuciluan
Copy link

Not working in vivo x21

@thekarthiksankar
Copy link

@xuciluan Have you found any alternatives for vivox21?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment