DraggableSquareView.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:Tribe 作者:
public DraggableSquareView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mDragHelper = ViewDragHelper
            .create(this, 10f, new DragHelperCallback());
    moveDetector = new GestureDetectorCompat(context,
            new MoveDetector());
    moveDetector.setIsLongpressEnabled(false); // 不能处理长按事件,否则违背最初设计的初衷
    spaceInterval = (int) getResources().getDimension(R.dimen.drag_square_interval); // 小方块之间的间隔

    // 滑动的距离阈值由系统提供
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    anchorHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (draggingView != null) {
                // 开始移动重心的动画
                draggingView.startAnchorAnimation();
            }
        }
    };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号