title: Android view.setX()/setY() according accelerometer changes, show motion trail animation
body: <p>I am trying to implement something like:<br>
  motion trail animation<br>
  motion blur animation<br>
  ghost animation<br>
  (i do not know correct name of "effect") for repeatedly change view position.</p>
  
  <p>Function, which is called repeatedly according accelerometer changes:</p>
  
  <pre><code>public void setXY(float x, float y) {
      if(view != null) {
          overloadPoint.setX(pointX);
          overloadPoint.setY(pointY);
      }
  }
  </code></pre>
  
  <p>My goal:<br>
  For change X,Y animation show path (line, curve) between old and new view position.</p>
  
  <p>OR alternative goal:<br>
  Between old and new view position, i would like to freeze old position and apply for example alpha effect to view in old position from 1.0f to 0.0f, duration:100ms. So when method is called for example every 50ms, i will see two views. Both views will have fade out effect (alpha 1.0f -> 0.0f), but older will have less alpha.   </p>
  
  <p>For: API >= 21</p>
  
  <p>I tried:    </p>
  
  <pre><code>public void setXY(float x, float y){
      final View view = new View(this);
      view.setLayoutParams(new LinearLayout.LayoutParams(
              25, //TODO
              25)); //TODO
      view.setBackgroundResource(R.drawable.background_point);
      relativeLayout.addView(view);
      view.setX(x);
      view.setY(y);
  
      //Variant 1:
      view.animate()
              .alpha(0f)
              .setDuration(750)
              .setInterpolator(new DecelerateInterpolator())
              .withLayer()
              .setListener(new AnimatorListenerAdapter() {
                  @Override
                  public void onAnimationEnd(Animator animation) {
                      super.onAnimationEnd(animation);
                      relativeLayout.removeView(view);
                  }
              })
              .start();
  
      //Variant 2:
      /*AlphaAnimation anim1 = new AlphaAnimation(1f, 0f);
      anim1.setDuration(750);
      //anim1.setFillAfter(true);
      anim1.setAnimationListener(new Animation.AnimationListener() {
          public void onAnimationStart(Animation anim) {};
          public void onAnimationRepeat(Animation anim){};
          public void onAnimationEnd(Animation anim) {
              relativeLayout.removeView(view);
          };
      });
      view.startAnimation(anim1);*/
  
      //Variant 3:
      /*view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
      ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0f);
      // Add a listener that does cleanup
      animator.addListener(new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
              relativeLayout.removeView(view);
              view.setLayerType(View.LAYER_TYPE_NONE, null);
          }
      });
      animator.start();*/
  }
  </code></pre>
  
  <p>But i think, that these are not good solutions.. repeatedly create and remove Views. Better will be effect with one View.</p>
  
  <p>Thank you.</p>