xとyのどちらの方向にも回転させずに回転させたい矢印のドロアブルがあります。 さらに説明すると、固定点または円形のAndroidプログレスバーについてボールが回転しているとします。 さらに、ドロアブルは、クリックされると-180度、再びクリックされると180度回転します。矢印のドローラブルを中心に回転させる方法
これはプログラムで実行できますか?
更新 ジェイソンWihardjaの答えから、私はこれを達成することができました:とにかく、私はアニメーションの建物の繰り返しを避けることができ
@Override
public void onClick(View v) {
if (v.getId() == imageButton.getId()) {
int visibilty =newsBody.getVisibility();
if (visibilty == View.VISIBLE) {
Animation animation = new RotateAnimation(180.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation.setInterpolator(new DecelerateInterpolator());
animation.setRepeatCount(0);
animation.setFillAfter(true);
animation.setDuration(300);
imageButton.startAnimation(animation);
newsBody.setVisibility(View.GONE);
} else {
Animation animation = new RotateAnimation(0.0f, 180.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation.setInterpolator(new DecelerateInterpolator());
animation.setRepeatCount(0);
animation.setFillAfter(true);
animation.setDuration(300);
imageButton.startAnimation(animation);
newsBody.setVisibility(View.VISIBLE);
}
}
}
をしかし、あるのでしょうか?一度構築するだけで、クリックごとに度を切り替えるようにします。
「android.graphics.drawable.RotateDrawable」を使用 – pskink
恐らく重複:http://stackoverflow.com/questions/3496036/rotate-bitmap-on-android-canvas – user1676075
@ user1676075矢印は、 res/drawableフォルダにあり、ImageButtonの 'src'として使用しています。 – X09