亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在Android中進行平滑的圖像旋轉?

如何在Android中進行平滑的圖像旋轉?

大話西游666 2019-12-07 16:23:43
我正在使用RotateAnimation旋轉要用作Android中自定義循環微調器的圖像。這是我的rotate_indefinitely.xml文件,放置在res/anim/:<?xml version="1.0" encoding="UTF-8"?><rotate    xmlns:android="http://schemas.android.com/apk/res/android"    android:fromDegrees="0"    android:toDegrees="360"    android:pivotX="50%"    android:pivotY="50%"    android:repeatCount="infinite"    android:duration="1200" />    當我將此應用到我的ImageViewusing時AndroidUtils.loadAnimation(),它很好用!spinner.startAnimation(     AnimationUtils.loadAnimation(activity, R.anim.rotate_indefinitely) );一個問題是,圖像旋轉似乎在每個循環的頂部暫停。換句話說,圖像旋轉360度,短暫暫停,然后再次旋轉360度,依此類推。我懷疑問題在于動畫使用的是默認插值器,如android:iterpolator="@android:anim/accelerate_interpolator"(AccelerateInterpolator),但我不知道如何告訴它不要插值動畫。如何關閉插值(如果確實存在問題)以使動畫循環流暢?
查看完整描述

3 回答

?
收到一只叮咚

TA貢獻1821條經驗 獲得超5個贊

我也遇到了這個問題,并嘗試在xml中設置線性插值器而沒有成功。對我有用的解決方案是在代碼中將動畫創建為RotateAnimation。


RotateAnimation rotate = new RotateAnimation(0, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

rotate.setDuration(5000);

rotate.setInterpolator(new LinearInterpolator());


ImageView image= (ImageView) findViewById(R.id.imageView);


image.startAnimation(rotate);


查看完整回答
反對 回復 2019-12-07
  • 3 回答
  • 0 關注
  • 534 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號