2017-08-02 3 views
0

このXMLをRotateAnimation()形式でjavaのfloat値で変換する方法は?

<rotate 
    android:duration="5000" 
    android:fromDegrees="270" 
    android:pivotX="50%" 
    android:pivotY="100%" 
    android:repeatCount="0" 
    android:startOffset="0" 
    android:toDegrees="360" /> 

I)は、(それゆえRotateAnimationを考えて、動的度を通過したいです。しかし、すべての引数をRotateAnimationコンストラクタの必要に応じてfloatに変換することはできません。

+0

ので、どのような引数は、あなたは変換することはできませんか? – pskink

+0

toDegrees引数を動的値として渡したいと思います。 – Neha

+0

したがって、 'toDegrees'パラメータを取る' RotateAnimation'コンストラクタを使用してください。 – pskink

答えて

0

あなたの通常のImageViewで回転アニメーションを使用してください。

Matrix matrix = new Matrix(); 
imageView.setScaleType(ImageView.ScaleType.MATRIX); //required 
matrix.postRotate((float) angle, pivotX, pivotY); 
imageView.setImageMatrix(matrix); 
+0

Mahesh、私は画像を動的に回転させたい。私はXMLを関与させたくありません。 – Neha

+0

@Neha私の編集した回答を参照 –

+0

ありがとう、しかし私はそれを他の方法で解決しました! – Neha

0

これは私のために働いている:

int i=seekbar.getProgress(); 
i=i-90; 
float **newFloat** = (float) i; 
rotation= new RotateAnimation(-90f,**newFloat**,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,1.0f); 

rotation.setDuration(5000); 
rotation.setFillAfter(true); 
two.startAnimation(rotation); //two is an imageview 
関連する問題