title: How to change Frame Rate or FPS of animation dynamically?
body: <p>I am creating an app which rotate square in 360 degree in 10 seconds. Now it has default frame rate. But I want to change its frame rate but it should rotate 360 degree in 10 seconds. Means no matter what frame rate is it should complete 360 degree in 10 sec. </p>
  
  <p>I am using view and draw to do this.
  Is there any other way to do this?</p>
  
  <p>Thanks in Advance.
  Here is my code.</p>
  
  <pre><code> public class Square extends View  {
  
  private Rect rect;
  private Paint paint;
  float height1;
  float width1;
  
   public Square(Context context)
   {
  
       super(context);
       DisplayMetrics displaymetrics = new DisplayMetrics();
       ((Activity)      getContext()).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
        int height = displaymetrics.heightPixels;
       int width = displaymetrics.widthPixels;
       height1=height;
       width1=width;
  
      Point cos = new Point(width/2,height/2);
       int left = cos.x-(200);
      int top = cos.y - 200;
       int right =cos.x+200;
       int bottom = cos.y+200;
  
       rect = new Rect(left,top,right,bottom);
  
       // create a rectangle that we'll draw late rect = new Rect(x, y,  sideLength, sideLength);
  
       // create the Paint and set its color
      paint = new Paint();
  
  
  
  
  
  
   }
  
  
   protected void onDraw(final Canvas canvas) {
  
  
      super.onDraw(canvas);
    /* canvas.drawColor(Color.BLACK);
      canvas.drawRect(rect, paint);*/
      //canvas.drawColor(Color.BLACK);
      long time1 = System.nanoTime();
      paint.setStyle(Paint.Style.FILL);
      paint.setColor(Color.WHITE);
      canvas.drawRect(rect, paint);
  
  
      // border
      paint.setStyle(Paint.Style.STROKE);
      paint.setColor(Color.GREEN);
      canvas.drawRect(rect, paint);
  
      long ti = animate().getDuration();
      String x = "hello";
  
      //Log.e("Tag",x+ti);
  
      long lsttime = System.nanoTime();
      double fps = 100000000.0 / (lsttime - time1);
      animate().rotation(360).setDuration(10000).start();
  
  
      String fpss = "" + fps;
      Log.e("Tag", fpss);
    }
  
  }  
  </code></pre>