문제

Is it possibble to Limit the touch event of the SlidingPaneLayout to the very left edge of the screen link happens in the DrawerLayout?

도움이 되었습니까?

해결책

Yes, but you want to create your own implementation of SlidingPaneLayout and override onTouchEvent(MotionEvent ev) method, like this

public class SlidingPaneLayoutExtended extends SlidingPaneLayout {

public static final int DEFAULT_DRAGGING_START_X = -1;
public static final int SLIDE_FROM_LEFT_EDGE = 0;

private int startDraggingX = DEFAULT_DRAGGING_START_X;

public SlidingPaneLayoutExtended(Context context, AttributeSet attrs) {
    super(context, attrs);
}


public int getStartDraggingX() {
    return startDraggingX;
}

public void setStartDraggingX(int startX) {
    this.startDraggingX = startX;
}

@Override
public boolean onTouchEvent(MotionEvent ev) {

    if (startDraggingX > DEFAULT_DRAGGING_START_X) {
        if ((startDraggingX == SLIDE_FROM_LEFT_EDGE && ev.getAction() == )
                || ev.getX() <= DEFAULT_DRAGGING_START_X) {
            return super.onTouchEvent(ev);
        } else {
            return false;
        }
    }

    return super.onTouchEvent(ev);
}
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top