关于ViewDragHelper

来源:互联网 发布:淘宝网秋装新款 编辑:程序博客网 时间:2024/06/08 18:37
/**             * 经测试left是child距离其父容器左边的距离(父容器的padding也算),dx是距离其初始位置的相对值,偏左为负             * 偏右为正             * 返回值是child距离父容器左边的距离范围(不能写死)             */            @Override            public int clampViewPositionHorizontal(View child, int left, int dx) {//                Log.e("aaaaaa",left+"aa"+dx);//                return 0;            final int leftBound = getPaddingLeft();                final int rightBound = getWidth() - child.getWidth() - leftBound;                final int newLeft = Math.min(Math.max(left, leftBound), rightBound);                Log.e("aaaaaa", leftBound+"aaaaaa"+rightBound+"aaaaaa"+left+"aaaaaa"+newLeft);                return newLeft;            }




0 0
原创粉丝点击