为了账号安全,请及时绑定邮箱和手机立即绑定

安卓动画可自行旋转图像

安卓动画可自行旋转图像

慕码人2483693 2022-09-21 16:40:24
我想制作一个动画,以便在自身上旋转图像(通过x轴)。就像这样: 我以前没有找到类似的东西,我已经尝试了一些技巧,比如:public static void coinAnimation(final View v){    RotateAnimation anim = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);    anim.setInterpolator(new LinearInterpolator());    anim.setRepeatCount(Animation.INFINITE);    anim.setDuration(700);    v.startAnimation(anim);    new Handler().postDelayed(new Runnable() {        @Override        public void run() {            v.setAnimation(null);        }    }, 2000);}
查看完整描述

2 回答

?
BIG阳

TA贡献1859条经验 获得超6个赞

这是答案,尽管它仅适用于3.0及更高版本。


1)创建一个名为“动画师”的新资源文件夹。


2)创建一个新的.xml文件,我称之为“翻转”。使用以下 XML 代码:


<?xml version="1.0" encoding="utf-8"?>

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"

    android:valueFrom="0" android:valueTo="360" android:propertyName="rotationY" >

</objectAnimator>

不可以,对象动画器标记不以大写字母“O”开头。


3) 使用以下代码开始动画:


ObjectAnimator anim = (ObjectAnimator) AnimatorInflater.loadAnimator(mContext, R.animator.flipping); 

anim.setTarget(A View Object reference goes here i.e. ImageView);

anim.setDuration(3000);

anim.start();


查看完整回答
反对 回复 2022-09-21
?
翻阅古今

TA贡献1780条经验 获得超5个赞

这是一个伟大的图书馆与一堆动画。


尝试YoYo动画任何类型的视图。


在应用程序的生成.gradle 文件中添加以下依赖项


dependencies {

        compile 'com.android.support:support-compat:25.1.1'

        compile 'com.daimajia.easing:library:2.0@aar'

        compile 'com.daimajia.androidanimations:library:2.3@aar'

}

例:


YoYo.with(Techniques.FlipOutY)

.duration(700)

.repeat(5)   // If you want to do INFINITELY then set "-1" value here

.playOn(findViewById(R.id.edit_area));


查看完整回答
反对 回复 2022-09-21
  • 2 回答
  • 0 关注
  • 141 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号