添加可拖动的浮动视图
I already readed this Android floating view (over other views)
And I already know and did myself it to add Views in top of other views.
My problem now, is that I need to drag these Views around, and I don't have idea how to translate then.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 TranslationAnimation,但视图只会“显示”在不同的位置。点击目标将保留在同一位置。
您可以尝试的是使用 bitmapCache 创建视图的位图,将其拖动,当您放下它时,可以使用 LayoutParams 的绝对值或在其单元格中使用类似于 gridview 的内容将视图移动到新位置你把拖动的视图。有点像在启动器应用程序中完成的那样。视图将以这种方式卡入到位。
这有道理吗?可能不是:)
也可以对 LayoutParams 中的边距进行动画处理,并为每个 touchEvent 在父级上调用 requestLayout...还没有尝试过。
You could use a TranslationAnimation but then the views would only be "displayed" at a different position. The click targets would remain in the same spot.
What you could try is to make create a bitmap of the view using bitmapCache, drag that around and when you drop it move the view to the new position either using absolute values for your LayoutParams or by having something like a gridview underneath it in whose cells you put the draged view. Kinda like its done in the launcher app. The views would snap into position this way.
Does this make sense ? Pobably not :)
It might also be possible to animate the margins in the LayoutParams and call requestLayout on the parent for each touchEvent... havent tried.
我想向您指出此教程。我认为这就是您正在寻找的内容。 :)
I would like to point you to this tutorial. I think its what you are searching about. :)