直接將RefreshProgress添加進xml中當做ImageView就能使用 package com.example.administrator.superrefresh; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.drawable.BitmapDrawable; import android.util.AttributeSet; import android.view.animation.Animation; import android.view.animation.LinearInterpolator; import android.view.animation.RotateAnimation; import android.widget.ImageView; /** * Created by SLY on 2015/9/6. */ public class RefreshProgress extends ImageView { private Matrix m = new Matrix(); //勻速加速器 private LinearInterpolator lir = new LinearInterpolator(); public RefreshProgress(Context context) { super(context); } public RefreshProgress(Context context, AttributeSet attrs) { super(context, attrs); } public void changeAnimation(int num){ m.reset(); // Bitmap bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.loading_rotate)) .getBitmap(); this.setImageBitmap(bitmap); //顯示圖像 // m.setRotate(num); Bitmap newBitmap = Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),m,true); BitmapDrawable bd = new BitmapDrawable(newBitmap); this.setImageDrawable(bd); //顯示新的圖像 } //控制動畫 public void Animation(){ RotateAnimation rotate = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); //默認為0,為-1時一直循環(huán)動畫 rotate.setRepeatCount(-1); //添加勻速加速器 rotate.setInterpolator(lir); rotate.setDuration(2000); rotate.setFillAfter(true); this.startAnimation(rotate); } }
網(wǎng)站欄目:Android實現(xiàn)可旋轉(zhuǎn)的ImageView
標題URL:http://muchs.cn/article18/ppjsgp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷、服務(wù)器托管、標簽優(yōu)化、網(wǎng)站設(shè)計公司、ChatGPT、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)