Last active
May 13, 2022 07:09
-
-
Save haxzie-xx/453a26c02e496fb9a97821c7eee6bde7 to your computer and use it in GitHub Desktop.
Android fullscreen dialog
This file contains hidden or 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 String TAG = "FullScreenDialog"; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setStyle(DialogFragment.STYLE_NORMAL, R.style.FullScreenDialogStyle); | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
super.onCreateView(inflater, container, savedInstanceState); | |
View view = inflater.inflate(R.layout.layout_full_screen_dialog, container, false); | |
Toolbar toolbar = view.findViewById(R.id.toolbar); | |
toolbar.setNavigationIcon(R.drawable.ic_close_white_24dp); | |
toolbar.setNavigationOnClickListener(view1 -> cancelUpload()); | |
toolbar.setTitle("Uploading"); | |
return view; | |
} | |
@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); | |
} | |
} | |
} |
This file contains hidden or 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"?> | |
<android.support.design.widget.CoordinatorLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/colorWhite"> | |
<android.support.design.widget.AppBarLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" > | |
<android.support.v7.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"></android.support.v7.widget.Toolbar> | |
</android.support.design.widget.AppBarLayout> | |
<FrameLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:layout_behaviour="@string/appbar_scrolling_view_behavior"> | |
<!-- YOUR CUSTOM VIEWS HERE --> | |
</FrameLayout> | |
</android.support.design.widget.CoordinatorLayout> |
This file contains hidden or 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"?> | |
<set xmlns:android="http://schemas.android.com/apk/res/android"> | |
<translate | |
android:duration="@android:integer/config_mediumAnimTime" | |
android:fromYDelta="0%p" | |
android:interpolator="@android:anim/accelerate_interpolator" | |
android:toYDelta="100%p" /> | |
</set> |
This file contains hidden or 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"?> | |
<set xmlns:android="http://schemas.android.com/apk/res/android"> | |
<translate | |
android:duration="@android:integer/config_mediumAnimTime" | |
android:fromYDelta="100%" | |
android:interpolator="@android:anim/accelerate_interpolator" | |
android:toXDelta="0" /> | |
</set> |
This file contains hidden or 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="Theme.AppCompat.Dialog"> | |
<item name="android:windowNoTitle">true</item> | |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
<item name="colorPrimary">@color/colorPrimary</item> | |
<!-- Set this to true if you want Full Screen without status bar --> | |
<item name="android:windowFullscreen">false</item> | |
<item name="android:windowIsFloating">false</item> | |
<!-- This is important! Don't forget to set window background --> | |
<item name="android:windowBackground">@color/colorWhite</item> | |
<!-- Additionally if you want animations when dialog opening --> | |
<item name="android:windowEnterAnimation">@anim/slide_up</item> | |
<item name="android:windowExitAnimation">@anim/slide_down</item> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment