如何在安卓中创建循环列表视图?

3
我希望创建一个视图,其中物品的查看将呈圆形。这里我分享我的图片来描述我的要求。
物品数量将是动态的。

circular items

有人能推荐这种东西的库吗?

1个回答

2

您需要检查这个库:WheelView

将依赖项添加到您的build.gradle中。

dependencies {
   compile 'com.github.lukedeighton:wheelview:0.3.1'
}

将自定义视图添加到您的XML中

<com.lukedeighton.wheelview.WheelView
    android:id="@+id/wheelview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:wheelColor="@color/grey_400"
    app:rotatableWheelDrawable="false"
    app:selectionAngle="90.0"
    app:wheelPosition="bottom"
    app:wheelOffsetY="60dp"
    app:repeatItems="true"
    app:wheelRadius="276dp"
    app:wheelItemCount="14"
    app:wheelPadding="13dp"
    app:wheelItemRadius="43dp"/>

在Java代码中设置适配器

wheelView.setAdapter(new WheelAdapter() {
    @Override
    public Drawable getDrawable(int position) {
        //return drawable here - the position can be seen in the gifs above
    }

    @Override
    public int getCount() {
        //return the count
    }
});

enter image description here


谢谢您的快速回复。我会检查它。 - Himanshu Mori
1
不错的库.. 同时我也发现了另一个好的库... https://github.com/ogaclejapan/ArcLayout - Himanshu Mori
在WheelView库中,我无法设置自己的视图项。只有图像可绘制对象可以设置为轮适配器。如何在其中设置视图项?因为我还需要设置TextView的值。 - Himanshu Mori
嗨@HimanshuMori,你找到解决方法了吗?我也遇到了同样的问题。 - Mohit Lakhanpal

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接