如何在 Android 中创建 Circular Reel 视图?

How to create Circular Reel view in Android?

如何在 Android 中创建这样的视图?我使用可绘制的圆形创建了圆形主框架图像

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >
    <solid android:color="#000"/> <!-- this one is ths color of the  Rounded Button -->
    <corners
        android:bottomRightRadius="100dp"
        android:bottomLeftRadius="100dp"
        android:topLeftRadius="100dp"
        android:topRightRadius="100dp"/>
</shape>

如何将内部图像放置在这个圆形框架中?

使用您的 Circular Reel 图像作为蒙版:剪切图片槽,使图片所在位置的 alpha 为零。您将在图片的顶部最后绘制此图像。

每个插槽中的每张图像都需要旋转并平移到插槽位置。首先旋转图像(围绕图像的中心),然后将图像平移到它的插槽中。

您不需要动态执行此操作,因为插槽都是固定的。这意味着您使用普通的旧笔和纸计算图像变换,然后手动将每个变换构建到您的布局标记中。一些有用的公式来自极坐标系 (r, theta) 和笛卡尔 (x,y) 的转换。图片中我所有的数学都是以度为单位,但你最好以弧度为单位。

R为圆的半径,即卷轴中心到视窗中心线的距离

如果我是你(并且如果你想动态更改图像),那么我会了解如何为每个转换指定一个空槽并在 post facto 中添加图像。

练习将单个图像排成一行,然后计算其余位置的数学。