如何在Android中制作类似滚动壁纸的背景图片?
我使用基于导航的 iOS 应用程序。我想在Android中制作一个类似于桌面壁纸的背景。 因此,当我转到另一个视图时,当前视图及其内容会移到屏幕之外,但背景图像只会稍微移动。 请参阅此处的示例屏幕截图。
I use a navigation-based iOS application. I want to make a background similar to desktop wallpaper in Android.
So when I go to another View the current View and it's content goes outside of the screen but the background image slightly moves only.
See a sample screenshot here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不将基本子视图设置为背景壁纸的大小(即大于屏幕宽度)并从左对齐开始。然后在其上添加一个分页的 UIScrollView 。当用户滚动
UIScrollview
时,挂钩到UIScrollViewDelegate
方法-scrollViewDidScroll:
并将其传递给基本子视图,告诉它按照动画进行动画处理。这应该不会太难,但您可能需要稍微调整一下以获得您想要的感觉。尝试使用
UIScrollViewDelegate
协议中的各种委托方法来确定最佳时间开始动画。Why not have the base subview set to the size of the background wallpaper (ie larger than the screens width) and start with it left aligned. Then have a paged
UIScrollView
on top of that. When the user scrolls theUIScrollview
, hook into theUIScrollViewDelegate
method- scrollViewDidScroll:
and pass it through the the base subview, telling it to animate in accordance.This shouldn't be too hard but you'll probably want to tweak it a bit to get the feel you want.Try playing about with the various delegate methods in the
UIScrollViewDelegate
protocol to determine the best time to start the animation.