Android 向下移动幻灯片以向上滑动视图

Android move slide down to slide up view

我正在使用 this library 来使用向下滑动菜单,问题是当我想从上到下移动手柄并想从向下滑动更改为向上滑动时,我尝试更改可变但不能正确

这是原代码

/* User tapped down on screen. */
                    case MotionEvent.ACTION_DOWN:
                        // User has tapped the screen
                        yStart = event.getRawY();
                        lastY = event.getRawY();
                        currentHeight = slideDownView.getHeight();
                        break;

                    /* User is dragging finger. */
                    case MotionEvent.ACTION_MOVE:

                        // Calculate the total height change thus far.
                        float totalHeightDiff = event.getRawY() - yStart;

                        // Adjust the slide down height immediately with touch movements.
                        LayoutParams params = slideDownView.getLayoutParams();
                        params.height = (int)(currentHeight + totalHeightDiff);
                        slideDownView.setLayoutParams(params);

                        // Check and set which direction drag is moving.
                        if (event.getRawY() > lastY) {
                            directionDown = true;
                        } else {
                            directionDown = false;
                        }

                        // Set the lastY for comparison in the next ACTION_MOVE event.
                        lastY = event.getRawY();
                        break;

                    /* User lifted up finger. */
                    case MotionEvent.ACTION_CANCEL:
                    case MotionEvent.ACTION_UP:

                        /*
                         * Need to snap either up or down. Using ValueAnimator to "finish" the action. 
                         * HeightEvaluator is a custom class. 
                         * 
                         * NOTE: I'm using the nineoldandroids library for 
                         */
                        if (directionDown) {

                            // Open the sliding view.
                            int startHeight = slideDownView.getHeight(); 

                            ValueAnimator animation = ValueAnimator.ofObject(
                                    new HeightEvaluator(slideDownView),
                                    startHeight, 
                                    (int) openHeight).setDuration(300);

                            // See Table 3 for other interpolator options 
                            // - http://developer.android.com/guide/topics/graphics/prop-animation.html
                            animation.setInterpolator(new OvershootInterpolator(1));
                            animation.start();

                        } else {

                            // Close the sliding view.
                            int startHeight = slideDownView.getHeight(); 
                            ValueAnimator animation = ValueAnimator.ofObject(
                                    new HeightEvaluator(slideDownView),
                                    startHeight, 
                                    (int) closedHeight).setDuration(300);
                            animation.setInterpolator(new OvershootInterpolator(1));
                            animation.start();
                        }
                        break;

如何让它反转?这样我就可以从底部向上滑动?是否也必须在 HeightEvaluator.java 中更改?

最后我使用 BottomSheet 并设置 PeekHeight 制作一个 slideUp,底部的按钮仍然可见以触发 slideView