Last active
June 20, 2022 15:50
-
-
Save koocbor/88db64192638bff09aa4 to your computer and use it in GitHub Desktop.
Full Screen Dialog in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FullScreenDialog dialog = new FullScreenDialog(); | |
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); | |
dialog.show(ft, FullScreenDialog.TAG); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not working in vivo x21