【问题标题】:Flip animation to disable button翻转动画以禁用按钮
【发布时间】:2015-06-25 21:03:12
【问题描述】:

我正在开发一个简单的动画 UI,应该将按钮从启用更改为禁用。但与其简单地将颜色从红色更改为灰色,我更希望按钮翻转。

我尝试了单击按钮时的简单动画,但我所能做的就是旋转按钮。

对如何创建翻转动画有帮助吗?

【问题讨论】:

  • 到目前为止你尝试了什么?
  • 我用 元素创建了简单的 R.anim.test_rotate 并以 button.startAnimation(AnimationUtils.loadAnimation(context, R.anim.test_rotate)); 开头
  • @Mazmat 你解决了你的问题吗..?如果我没有尝试发布答案

标签: android user-interface animation


【解决方案1】:

翻转动画:

<set android:ordering="sequentially">
<objectAnimator android:duration="2000" 
android:propertyName="rotationY"
android:valueFrom="0" 
android:valueTo="360">
</objectAnimator>
</set>

在课堂上:

AnimatorSet set;
set = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.anim.flipping);
set.setTarget(img_logo);
set.start();

Timer timer = new Timer();
timer.schedule(task, 2000);

【讨论】:

  • objectAnimator 在 R.anim 中无效
  • 我在我的应用程序中使用了它,它在 Play 商店中运行并且工作正常。
  • 实际上它正在工作。但我必须把它放到 R.animator 中,然后用 AnimatorInflator 创建它。
  • 检查我更新的代码。我想你在谈论这个。
【解决方案2】:

试试这个:

test_rotate.xml

<?xml version="1.0" encoding="utf-8"?>
<scale
    xmlns:android="http://schemas.android.com/apk/res/android"
       android:fromXScale="0.0" android:toXScale="1.0"
       android:pivotX="50%"
       android:fromYScale="1.0" android:toYScale="1.0"
       android:pivotY="50%"
       android:duration="250" />

【讨论】:

    猜你喜欢
    • 2011-10-31
    • 1970-01-01
    • 2016-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-14
    • 2016-02-22
    • 2018-04-22
    相关资源
    最近更新 更多