安卓:屏幕外拖动查看 [英] Android: Drag View outside screen

查看:178
本文介绍了安卓:屏幕外拖动查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动,用户可以拖拽周围的一些按钮。
我所有的可拖动的观点是在 RelativeLayout的键,拖动周围我改变自己的边距和左边距。
一切都运行完美,只是当我拖到靠近右边,屏幕底部边缘的看法,他们反而缩水的屏幕外正在制定。 有没有什么方法具有在屏幕上的所有边缘相同的行为(目前只有正常工作的顶部和左侧边缘)。

I have an activity where users can drag and drop around some buttons.
All my draggable views are inside a RelativeLayout and to drag them around I change their top and left margins.
Everything works perfect, except that when I drag the views close to the right and bottom edge of the screen, they shrink instead of being drawn outside the screen. Is there any way for having the same behaviour on the all edges of the screen (currently only works fine on the top and left edge).

我想我可以有一个左侧和顶部切缘阴性。但是,当我有留有余量>屏幕宽度上边距>屏幕高度图像缩小。

I guess I can have a left and top negative margin. But when I have left margin > screen width or top margin > screen height the images shrink.

感谢您的帮助。

推荐答案

要实现内部的的ViewGroup 最好的办法是实现自定义的<$ C意见自定义定位$ C>的ViewGroup 覆盖 onLayout()

To implement custom positioning of views inside a ViewGroup the best way is to implement your custom ViewGroup overriding onLayout().

这并不难,我解释了如何做到这一点这里。 (问题是新的,有更多的可见性)

It is not that difficult and I explained how to do it here. (the question is newer and has more visibility)

修改: 您可能还需要寻找到拖放阿比这里 。感谢Zainodis的评论。

Edit: You might also want to look into the Drag and Drop Api here. Thanks to Zainodis for the comment.

这篇关于安卓:屏幕外拖动查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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