Android 圆形画廊?
我是android开发的新手。现在我想做如下图所示的圆形图库视图。事情是,当用户从左到右和从右到左滚动时,我想放大中心图像。有相关教程吗?
我想要的是被滑动的图像在中心时需要被放大。我想我可以用画廊来做到这一点。但 android 开发人员提供的示例不是我想要的。 :(
I am a newbie to android development.Now i would like to do gallery view as circular like image as below.The things is that i want to enlarge the center image when user scroll from left to right and right to left. Is there any tutorials for that ?
what I want is the image that's been swiped need to be enlarged while it's at the center. I thought I could do it with Gallery. but the example from the android developer is not the one I want. :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以尝试:
youcan try:
如果您想放大中心选定的图像,有一种可能的方法。
在 onItemSelected 方法中,只需调用动画即可缩放对象。画廊的特性是它总是中心锁定的。所以中心元素将始终被选择。
希望这会起作用..
请记住,您必须存储以前的视图,因为当元素远离中心时,它应该被设置为正常大小。
所以你可以有两个视图 - prevView 和 currView。
在 currView 上做动画。
谢谢,
森
If you want to enlarge the center selected image there is one possible way.
On your onItemSelected method, just call an animation to zoom the object. The property of gallery is that it is always center-locked. So the center element will be always selected.
Hope that will work..
Do remember that you will have to store the previous view as when the element is move away from center it should be put to the normal size.
So you can have two views - prevView and currView.
Do the animation on the currView.
Thanks,
Sen
我为此创建了自己的教程:
http://evgeni-shafran.blogspot.com /2011/08/tutorial-custom-gallery-circular-and.html
为了使其成为循环,您需要让它认为它有很多项目,比您实际拥有的要多得多。
然后通过设置position=position%items.length你创建类似的东西(我将显示3个项目):1,2,3,1,2,3,1,2,3,1,2,3,1 ,2,3,1,2,3,1,2,3
然后走到中间,这样即使卷轴很多,他也不会接近结尾。
1,2,3,1,2,3,1,2,3,->1<-,2,3,1,2,3,1,2,3,1 ,2,3
要选择它:您需要重写 setOnItemSelectedListener 并操作大小。不要忘记保存对上一个视图的引用,这样当您到达下一个视图时,您可以使其看起来正常,而不是放大。
我在上面列出的教程中实现了这两个功能
I created my own tutorial for this:
http://evgeni-shafran.blogspot.com/2011/08/tutorial-custom-gallery-circular-and.html
For it to be circular you need to make it think that it have A LOT of items, a lot more then you really have.
And then by making position= position % items.length you create something like (I will show it for 3 items) : 1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3
And then go to the middle so even if the scroll a lot he wont come near to the end.
1,2,3,1,2,3,1,2,3,->1<-,2,3,1,2,3,1,2,3,1,2,3
For it to be selected: you need to override setOnItemSelectedListener and manipulate the size. dont forget to save a reference to your last view so when you get to the next one you can make it look regular, not enlarged.
I implemented both of this in my tutorial listed above