如何创建显示自定义视图的WheelPicker [英] How to create a WheelPicker that displays custom Views
问题描述
我有一个名为CustomProgressBar的自定义视图.我想要一个wheelView
,它将以CustomProgressBar Views列表作为其数据.
I have a custom View called CustomProgressBar. I want to have a wheelView
that will have a list of CustomProgressBar Views as its data.
CustomProgressBar的外观如下:
this is how a CustomProgressBar looks:
这就是我希望WheelView的外观(不完全是,但是这就是想法):
and this is how I want my WheelView to look (not exactly, but this is the idea):
我希望选定的CustomProgressBar的边框在onScroll时扩展,并在选定时重新缩小.
I want the border of the selected CustomProgressBar to expand when onScroll, and re-shrink when selected.
仅在可能的情况下,我希望它以3D形式出现,例如此处(只有3D效果,而不是外观)
Only if possible I'd like it to be in 3D, like in here (only the 3D effect, not the look)
因此,总而言之,我想要一个3D WheelPicker,它可以携带我的CustomProgressBar视图项,并且希望自定义选定项目的边框并对其进行动画处理,以在滚动时扩展并在选定项目上重新缩小.
So, to conclude, I want a 3D WheelPicker that can carry my CustomProgressBar View Items, and I want the selected-items border to be custom and animated to expand on scroll and re-shrink on the selected item.
预先感谢(:
推荐答案
我将结合 CarouselLayoutManager 的RecyclerView .
I would combine RecyclerView with CarouselLayoutManager.
我以前使用过它,并且效果很好,在您的recyclerView
中,您可以放置任何类型的视图(在您的情况下,只需放置CustomProgressBar)
I have used it before and it works great, in your recyclerView
you can put any type of view (In your case just put your CustomProgressBar)
如何根据Github页面使用:
-
实施:
Implementation:
//current latest vaersion is 1.2.4
implementation 'com.azoft.carousellayoutmanager:carousel:version'
在您的代码中:
In your code:
final CarouselLayoutManager layoutManager = new
CarouselLayoutManager(CarouselLayoutManager.VERTICAL);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
注意:这可以帮助您使用自定义在RecyclerView适配器中查看?
这篇关于如何创建显示自定义视图的WheelPicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!