首页 > 解决方案 > 单击箭头时如何为展开/折叠箭头设置 180 度动画?

问题描述

linearLayout在可展开的回收站视图中有一个展开更多图标

展开箭头图标

我想当点击 linearLayout 时,点击布局会展开,这个图标会像下面一样随着动画旋转 180 度 -

在此处输入图像描述

这是我的操作代码:

rotationAngle = rotationAngle == 0 ? 180 : 0;
expandArrow.animate().rotation(rotationAngle).setDuration(500).start();

whererotationalAngle=0;是全局声明的。

你能给我一个合适的解决方案吗?

标签: androidexpandablelistviewcollapseexpandexpandablerecyclerview

解决方案


ImageV.animate().rotation(isExpanded()? -180 : 0  )
                        .setInterpolator(new SineInOut60())
                        .setDuration(2000)
                        .withLayer();

推荐阅读