弹出窗口中类似放大镜的功能......如何?
我需要在我的应用程序中创建一个类似放大镜的功能。就像iPhone上的“放大镜”效果一样! 问题是我需要在弹出窗口内执行此操作,但我不知道如何使其工作!
弹出窗口显示我使用 shapeDrawables 生成并一一绘制的颜色网格。我想要的是显示更大的颜色,当用户触摸弹出窗口(颜色网格)并移动手指时放大它。这个想法是在颜色上创建跟踪缩放效果,以便用户可以更清楚地看到他的手指当前所在的颜色。
问题是:
- 我似乎无法在这个窗口之上创建另一个弹出窗口,我认为是 Android 的限制?
- 如果我修改当前的 shapeDrawable,调整它的大小,更改边界,它需要在生效之前重新显示弹出窗口(这当然是不可接受的)
那么,有人知道我可以在该弹出窗口上绘制的方法吗?
编辑:
我尝试使用自定义 Toast 对象解决此问题...但它并不能完全解决问题。它可以工作,但是 toast 对象出现缓慢,因此触摸运动与用户在颜色网格上的移动根本不同步。
I need to create a magnifier like feature in my app. Like the "loupe" effect on the iphone !
The problem is that I need to do that inside a popup window and I don't get how to make it work !
The popup window display a grid of colors that I generate and draw one by one using shapeDrawables. What I want is to display that color bigger, zoom on it when the user touch and move his finger around the popup window (color grid). The idea is to create a tracking-zooming effect on the colors so the user can see more clearly under wich color his finger is currently located.
Problems are :
- I can't seem to create another popup window on top of this one, Android limitation I think ?
- If I modify the current shapeDrawable, resize it, change the boundaries, It needs to re-display the popup window before it takes effect (which is not acceptable of course)
So, anyone knows of a way I could draw over that popup window ?
EDIT :
I've tried solving this issue using a Custom Toast object...But it doesn't quite do the trick. It works, but toast object appears slowly and so the touch motion is not in sync at all with the user movement over the color grid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否对您有帮助,但您也许可以通过使用第二个 Activity 来完成此任务...如果您在清单中包含以下属性,则第二个 Activity 将使用 Android 的半透明主题:
第二个活动现在将仅包含您在布局中放置的内容。也就是说......您正在运行的“真实”活动在其后面仍然可见(任何您没有用新布局中的视图覆盖它的地方)。
如果您确实想类似于弹出窗口,您也可能更喜欢 Theme.Dialog。
如果您采用这种方法,需要记住的一点是,您可能需要在新活动中重写 onWindowFocusChanged() ,并在失去焦点时重写 finish() 。此外,您还需要弄清楚如何在两个活动之间共享数据。
I'm not sure if this will help you or not, but you might be able to accomplish this by using a second Activity... this second Activity would use Android's translucent theme if you include the following attribute in your manifest:
<activity android:theme="@android:style/Theme.Translucent">
This second activity will now only contain what you place in your layout. That is... the "real" activity you're running will still be visible behind it (anywhere you don't cover it up with views in the new layout).
You also might prefer Theme.Dialog if you really want to resemble a popup.
Something to keep in mind if you take this approach is you will probably want to override onWindowFocusChanged() in the new activity, and finish() in the event of you losing focus. Additionally, you'll need to figure out how to share your data between the two activities.