android - Drag, Rotate and Zoom a relative layout -


i want rotate & scale in same time, it's flickering while rotating , scaling layout. code

public class customrelaytivelayout extends relativelayout implements rotationgesturedetector.onrotationgesturelistener {  private float scale = 1.0f; private float touchx = 0.0f; private float touchy = 0.0f; public scalegesturedetector mscaledetector; public rotationgesturedetector mrotationdetector; private customrelaytivelayout customrelaytivelayout_;   float mscalefactor = 1; float mpivotx; float mpivoty;  public customrelaytivelayout(context context) {     super(context);     mscaledetector = new scalegesturedetector(context, new scalelistener(this));     mrotationdetector = new rotationgesturedetector(this);     customrelaytivelayout_ = this; }  public customrelaytivelayout(context context, attributeset attrs) {     super(context, attrs);     mscaledetector = new scalegesturedetector(context, new scalelistener(this));     mrotationdetector = new rotationgesturedetector(this);     customrelaytivelayout_ = this; }  private class scalelistener extends scalegesturedetector.simpleonscalegesturelistener {      private customrelaytivelayout customrelaytivelayout;      float startingspan;      float endspan;     float startfocusx;     float startfocusy;      public scalelistener(customrelaytivelayout customrelaytivelayout_) {         customrelaytivelayout = customrelaytivelayout_;     }      @override     public boolean onscale(scalegesturedetector detector) {         // multiply scale factor         scale *= detector.getscalefactor();             viewhelper.setscalex(customrelaytivelayout,  scale);             viewhelper.setscaley(customrelaytivelayout,  scale);         invalidate();          return true;     }      @override     public boolean onscalebegin(scalegesturedetector detector) {         return true;     }      @override     public void onscaleend(scalegesturedetector detector) {       } }  private float angle = 0;  @override public void onrotation(rotationgesturedetector rotationdetector) {     angle = angle + rotationdetector.getangle();     log.d("tag_angle", "" + angle);     customrelaytivelayout_.setrotation(-angle); }  protected void dispatchdraw(canvas canvas) {     canvas.save(canvas.matrix_save_flag);     canvas.scale(mscalefactor, mscalefactor, mpivotx, mpivoty);     super.dispatchdraw(canvas);     canvas.restore(); }  public void scale(float scalefactor, float pivotx, float pivoty) {     mscalefactor = scalefactor;     mpivotx = pivotx;     mpivoty = pivoty;     this.invalidate(); }  public void restore() {     mscalefactor = 1;     this.invalidate(); } 

}

its flickering while rotating , scaling layout.if 1 have solution please share

thanks in advance


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -