Android FloatingActionButton忽略动画(KitKat)
我在xml布局中声明了一个Android FloatingActionButton忽略动画(KitKat),android,animation,android-4.4-kitkat,floating-action-button,Android,Animation,Android 4.4 Kitkat,Floating Action Button,我在xml布局中声明了一个FloatingActionButton <android.support.design.widget.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_mar
FloatingActionButton
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/random_button_margin"
android:onClick = "randomButtonPressed"
android:src="@mipmap/ic_dice"
android:id="@+id/randomButton"/>
及
我正在将这个应用程序编译到我的手机上(一款搭载安卓4.4.2的三星S4)
为什么我的按钮似乎无法设置动画?我认为您必须使用带有
FloatingActionButton
的较新按钮,而不是旧的视图动画。也就是说,android.animation
包中的类,而不是android.view.animation
@MikeM。那也没用<代码>ObjectAnimator.offload(findViewById(R.id.randomButton),“旋转”,0f,359f)@MikeM。踢我自己。你已经解决了它(你应该写一个答案)谢谢,但是在我能确认旧的视图动画不能与浮动动作按钮一起工作之前,我很犹豫是否要这么做。我先做点调查,然后再想想。这是可行的(但只有一次,然后引入了一个奇怪的阴影剪辑):ViewCompat.animate(findViewById(R.id.randomButton)).rotation(359.withLayer().setDuration(1000.setInterpolator)(新的Overshootterpolator()).start()
我认为您必须使用带有浮动操作按钮的较新版本,而不是旧的视图动画。也就是说,android.animation
包中的类,而不是android.view.animation
@MikeM。那也没用<代码>ObjectAnimator.offload(findViewById(R.id.randomButton),“旋转”,0f,359f)
@MikeM。踢我自己。你已经解决了它(你应该写一个答案)谢谢,但是在我能确认旧的视图动画不能与浮动动作按钮一起工作之前,我很犹豫是否要这么做。我先做点调查,然后再想想。这是可行的(但只有一次,然后引入了一个奇怪的阴影剪辑):ViewCompat.animate(findViewById(R.id.randomButton)).rotation(359.withLayer().setDuration(1000.setInterpolator)(新的Overshootterpolator()).start()代码>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0"
android:duration="1000"/>
</set>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fromDegrees="0"
android:toDegrees="359"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000" />
</set>
findViewById(R.id.mTextView).startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate))