0

i am creating an android app in which i want set delay in the rotation of needle when activity start anyone please tell me how to do this here is my code

 RotateAnimation ra = new RotateAnimation(currentDegree,altitude,
           Animation.RELATIVE_TO_SELF, 0.5f, 
           Animation.RELATIVE_TO_SELF,
           0.5f);


         ra.setDuration(1500);


         ra.setFillAfter(true);

         // Start the animation


         imageneedle.startAnimation(ra);
        currentDegree = altitude;

////

1 Answers1

0
public class StackOverflowActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ImageView iv_icon = (ImageView) findViewById(R.id.imageView1);

    Animation a = AnimationUtils.loadAnimation(this, R.anim.anim_img);
    a.setFillAfter(true);
    a.reset();

    iv_icon.startAnimation(a);
}
}

and the animatin xml is anim_img.xml,

<?xml version="1.0" encoding="UTF-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1600"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="358" />
JavaBuddy
  • 21
  • 4
  • i need to rotate a needle with dynamic value of – user3636257 May 14 '14 at 11:40
  • i need to rotate the nedle with value of public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_PRESSURE){ presure = event.values[0]; altitude = (int) SensorManager.getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, presure); altitude= (int) (altitude); – user3636257 May 14 '14 at 11:40