自定义 MyDragShadowBuilder 继承 View.DragShadowBuilder
public class MyDragShadowBuilder extends View.DragShadowBuilder {
private Point mScaleFactor;
public MyDragShadowBuilder(View arg0) {
super(arg0);
}
@Override
public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) {
// TODO Auto-generated method stub
int width, heigth;
// 设置拖动阴影的宽度/高度为原宽/高度的1.8倍
width = (int) (getView().getWidth() * 1.8);
heigth = (int) (getView().getHeight() * 1.8);
// 设置拖动阴影图像的宽度和高度
shadowSize.set(width, heigth);
// 设置手指在拖动图像的位置 设置为中点
shadowTouchPoint.set(width / 2, heigth / 2);
mScaleFactor = shadowSize;
}
@Override
public void onDrawShadow(Canvas canvas) {
// TODO Auto-generated method stub
canvas.scale(mScaleFactor.x/(float)getView().getWidth(),
mScaleFactor.y/(float)getView().getHeight());
getView().draw(canvas);
}
}