user6556461
user6556461

Reputation: 377

Sliding Up Screen Android

enter image description here

Whats the procedure of making this sliding screen. I am little bit confused. Is that Fragment which is sliding up or Activity and whats the after procedure?

Upvotes: 1

Views: 1037

Answers (2)

Umesh Singh Kushwaha
Umesh Singh Kushwaha

Reputation: 5741

This is android BottomSheetDialogFragment which is supported by android support library 23.2.

TO use this support library, add dependency in app's build.gradle

compile 'com.android.support:design:23.2.0'

You can create your own bottomsheetdialogfragment as follows:

public class TutsPlusBottomSheetDialogFragment extends BottomSheetDialogFragment {

    private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() {

        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            if (newState == BottomSheetBehavior.STATE_HIDDEN) {
                dismiss();
            }

        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
        }
    };

    @Override
    public void setupDialog(Dialog dialog, int style) {
        super.setupDialog(dialog, style);
        View contentView = View.inflate(getContext(), R.layout.fragment_bottom_sheet, null);
        dialog.setContentView(contentView);

        CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
        CoordinatorLayout.Behavior behavior = params.getBehavior();

        if( behavior != null && behavior instanceof BottomSheetBehavior ) {
            ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
        }
    }
}

To show :

BottomSheetDialogFragment bottomSheetDialogFragment = new TutsPlusBottomSheetDialogFragment();
bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());

For more details visit http://code.tutsplus.com/articles/how-to-use-bottom-sheets-with-the-design-support-library--cms-26031

https://github.com/Flipboard/bottomsheet

Upvotes: 1

slanecek
slanecek

Reputation: 808

This is called Parallax Scrolling. It can be achieved by many ways, for example by using the Google Design Support Library.

Edit: Of course, I may be mistaken, since your screenshot is just a screenshot and it could be a completely different effect.

Upvotes: 0

Related Questions