Sliding Drawer clickable contents while semi open

257 views Asked by At

I'm looking at implementing a semi closed sliding drawer with clickable features while the drawer is semi closed. However, upon closing the drawer, I find that the graphic may have been animated, but the clickable regions of the buttons have remained in the same position. I've tried to implement LayoutParams class, view.layout(), and view.offsetTopAndBottom() within the slider class under moveHandle() within the slidingdrawer class but to no avail. Here's a snippet of the moveHandle() method:

private void moveHandle(int position) {
    final View handle = mHandle;
    final View content = mContent;

    if (mVertical) {
        if (position == EXPANDED_FULL_OPEN) {
            handle.offsetTopAndBottom(mTopOffset - handle.getTop());
            invalidate();
        } else if (position == COLLAPSED_SEMI_CLOSED) {
            handle.offsetTopAndBottom(mBottomOffset + getBottom()- getTop()-
                    mHandleHeight - mSemiClosedContentSize - handle.getTop());
            invalidate();
        } else {
            final int top = handle.getTop();
            int deltaY = position - top;
            if (position < mTopOffset) {
                deltaY = mTopOffset - top;
            } else if (deltaY > mBottomOffset + getBottom()- getTop()- mHandleHeight - mSemiClosedContentSize - top) {
                deltaY = mBottomOffset + getBottom()- getTop()- mHandleHeight - mSemiClosedContentSize - top;
            }
            handle.offsetTopAndBottom(deltaY);

            final Rect frame = mFrame;
            final Rect region = mInvalidate;

            handle.getHitRect(frame);
            region.set(frame);

            region.union(frame.left, frame.top - deltaY, frame.right, frame.bottom - deltaY);
            region.union(0, frame.bottom - deltaY, getWidth(),
                    frame.bottom - deltaY + mContent.getHeight());

            invalidate(region);
        }

Anybody have a solution to moving the locations of the clickable buttons down when closing the SlidingDrawer?

Thank you.

Regards,

1

There are 1 answers

1
Clean Devs On BEST ANSWER

The SlidingDrawer is deprecated, reffering to the Android Documentation.

This class was deprecated in API level 17.

This means that Google are not supporting it anymore and you should not excect it to work properly.

I believe you should try to use a different implementation. You can look here for an option.