22

ドローアブルのアルファ化は、次のようにうまく機能します。

if(mAlphaAnimation == null){
        mAlphaAnimation = ObjectAnimator.ofFloat(this, "alpha", 0.0f,1.0f).setDuration(TARGET_ANIM_ALPHA_DURATION);
        mAlphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        mAlphaAnimation.setStartDelay(TARGET_ANIM_ALPHA_DELAY_BASE*power);
        mAlphaAnimation.setRepeatCount(ValueAnimator.INFINITE);
        mAlphaAnimation.setRepeatMode(ValueAnimator.REVERSE);
        mAlphaAnimation.addUpdateListener(this);
 }

しかし、下のようにドローアブルを回転させたい場合は、うまくいきません。

private void createRotateAnim(float fromDegress,float toDegress,int duration){
    if(mRotateAnimation == null){
        mRotateAnimation = ObjectAnimator.ofFloat(this, "rotation",fromDegress,toDegress).setDuration(duration);
        mRotateAnimation.setStartDelay(100);
        mRotateAnimation.setInterpolator(new AccelerateInterpolator());
        mRotateAnimation.addUpdateListener(this);
    }
}

誰でもこの問題を解決するのを手伝ってくれます。または、これらは回転ドローアブル アニメーションを作成する他の方法です。

下手な英語でごめんなさい。

4

2 に答える 2

19

この単純な回転アニメーションを画像に適用してみてください。

 ImageView imageview = (ImageView)findViewById(R.id.myimage);
 RotateAnimation rotate = new RotateAnimation(180, 360, Animation.RELATIVE_TO_SELF,    
 0.5f,  Animation.RELATIVE_TO_SELF, 0.5f);
  rotate.setDuration(500);
 imageview.startAnimation(rotate);

Viewこの回答は質問のためのものです。クリック可能な領域がの現在の位置とは異なることは正しいです。クリック可能な領域を正しくするには、この質問を確認してください。TranslateAnimation の後でボタンをクリックできない

于 2012-12-26T10:59:12.310 に答える