滑动屏幕Android
答
这是Android支持库支持的Android BottomSheetDialogFragment 23.2。
要使用该支持库,添加依赖于应用程序的的build.gradle
编译 'com.android.support:design:23.2.0'
您可以创建自己的bottomsheetdialogfragment为如下:
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);
}
}
}
要显示:
BottomSheetDialogFragment bottomSheetDialogFragment = new TutsPlusBottomSheetDialogFragment();
bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
答
这就是所谓的视差滚动。可以通过多种方式实现,例如使用Google设计支持库。
编辑:当然,我可能会误解,因为你的截图只是一个截图,它可能是一个完全不同的效果。
+0
否其视差不滚动。我认为它的片段从底部滑落到 – user6556461
难道滑动 - 只是过渡的动画,或者你可以保持它的手指和移动上述另一个一层? – Divers
@Divers将一个图层移动到另一个图层上方 – user6556461