【问题标题】:rotating an imageView from a fixed point从固定点旋转 imageView
【发布时间】:2021-09-12 08:10:58
【问题描述】:

我想创建一个仪表图并从其起点旋转指标 我正在努力实现这一目标

但指示器没有以正确的方式旋转 我也试过这个旋转

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

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

【问题讨论】:

  • “旋转方式不正确”,你能展示或描述一下它是如何旋转的吗?
  • 它在回收站视图中我不知道为什么它在动画结束@ShivamPuri 后返回到默认位置

标签: java android kotlin imageview gauge


【解决方案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) }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多