有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java从固定点旋转图像视图

我想创建一个仪表图表,并从其起点旋转指示器 我正在努力做到这一点

gauge chart

但指示灯旋转方向不正确 我也试过旋转

RotateAnimation(
                    0f, 180f, Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0f
                ).apply {
                    interpolator = LinearInterpolator()
                    duration = 5000
                    repeatCount = 0
                    imgGauge.startAnimation(this)
                }

它没有以正确的方式旋转,也在recyclerView中,当动画结束时,它会重置为默认值


共 (1) 个答案

  1. # 1 楼答案

    Animation.RELATIVE_TO_PARENT更改为Animation.RELATIVE_TO_SELF 并添加fillAfter = true以防止imageView重置为默认值

                        RotateAnimation(
                            0f, riskAngle, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0.5f
                        ).apply {
                            interpolator = BounceInterpolator()
                            duration = 750
                            fillAfter = true
                        }.also { image.startAnimation(this) }