拖放anumate影子回到原来的位置,如果没有降到目标 [英] drag and drop anumate shadow back to original position if not dropped to target

查看:317
本文介绍了拖放anumate影子回到原来的位置,如果没有降到目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已拖动的功能,并使用ondraglistener下降。它工作正常,但我的问题是,它是由不回原来的图像如果视图没有在目标投下了阴影。如何动画从位置阴影将原来position.any帮助

I have made the functionality of drag and drop using ondraglistener. Its working fine But my problem is the shadow which is made does not go back to original image if the view is not dropped at the target. how to animate going of shadow from the position to original position.any help

推荐答案

我们必须写我们自己的逻辑来移动它回来了,这就是我们要做的。

We have to write our own logic to move it to back, this is what we do.

一个OnDragListener添加到您的根视图,
在拖动查看等待ondrag当的(视图来看,事件的dragEvent)为ACTION_DRAG_ENDED。

Add a OnDragListener to your root view, in onDrag(View view, DragEvent event) of the dragged View wait for ACTION_DRAG_ENDED.

创建你的影子的形象副本。

create a image copy of your shadow.

Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
shadowBuilder.onDrawShadow(canvas);

创建与此位图的ImageView,并添加到您的视图层次的根视图。

Create as ImageView with this bitmap and add to the root view of your view hierarchy.

然后创建动画移动这回原来的位置并删除ImageView的。

Then you create Animator to move this back to the original position and remove the ImageView.

ObjectAnimator defaultChangeIn = ObjectAnimator.ofPropertyValuesHolder((Object)mImageView,
                pvhLeft, pvhTop, pvhRight, pvhBottom);

这篇关于拖放anumate影子回到原来的位置,如果没有降到目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆