您的位置:首页 > 移动开发 > Android开发

关于ViewDragHelper

2015-10-09 21:59 447 查看
/**
* 经测试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;

}




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android