如何在android中创建水平轮播视图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21905049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:17:51  来源:igfitidea点击:

How to create a horizontal carousel view in android?

androidcarousel

提问by Ari

In my Android application I want to implement Carousel for 7 views.

在我的 Android 应用程序中,我想为 7 个视图实现 Carousel。

My carousel has to show like the 1st image in this link

我的轮播必须像此链接中的第一张图片一样显示

carousel.

旋转木马.

I have checked out couple of links and some demo examples also like this one svn-link, but

我已经检查了几个链接和一些演示示例也像这个svn-link,但是

1st of all its for even number of views, where i have only 7 views

第一个是偶数次观看,我只有 7 次观看

secondly it adds all its content from attribute xml, I would prefer adding the views by code,

其次,它从属性 xml 添加所有内容,我更喜欢通过代码添加视图,

and I don't need a complete circular carousel, just an Arc shaped is fine with me.

而且我不需要一个完整的圆形转盘,只需要一个弧形就可以了。

Presently I have used coverflow, but experiencing too many bugs which is not so easy to solve.

目前我已经使用了coverflow,但是遇到了太多不太容易解决的错误。

Please help me with some demo, or example of carousel, simpler is better.

请帮我做一些演示,或者轮播的例子,越简单越好。

Or if using any other procedure I can show my list this way, any kind of ideas or hint is highly appreciated.

或者,如果使用任何其他程序,我可以以这种方式显示我的列表,任何类型的想法或提示都将受到高度赞赏。

Thanks

谢谢

回答by kylexy1357

See this coverflow widget, It's works like a listView so it is very simple to use :

看到这个coverflow小部件,它的工作原理就像一个listView,所以使用起来非常简单:

http://www.inter-fuser.com/2010/01/android-coverflow-widget.html

http://www.inter-fuser.com/2010/01/android-coverflow-widget.html

Steps :

脚步 :

  • Import library classes on your classpath
  • Instead of ListView, use CoverFlow;
  • Write your coverflowAdapter, here it will contains only images (see sample code from link)
  • Set the adapter to your coverflow
  • 在您的类路径上导入库类
  • 使用 CoverFlow 代替 ListView;
  • 编写您的coverflowAdapter,在这里它将只包含图像(请参阅链接中的示例代码)
  • 将适配器设置为您的 Coverflow

Hope it helps !

希望能帮助到你 !