Don't restore the Canvas until /after/ you super.dispatchDraw(). j
On Sun, Aug 2, 2009 at 10:32 AM, Moto<[email protected]> wrote: > > Hello, > I got this code from another post and modified it to work for me as a > TextView. I tried using the code below but no transformation is > happening? Can someone help me out see what's wrong? I trying to > draw the canvas of the TextView with the given Matrix transformation. > > Thanks! > Moto! > > > > import android.content.Context; > import android.graphics.Canvas; > import android.graphics.Matrix; > import android.util.AttributeSet; > import android.view.MotionEvent; > import android.widget.TextView; > > public class CTextView extends TextView > { > private Matrix mForward = new Matrix(); > private Matrix mReverse = new Matrix(); > private float[] mTemp = new float[2]; > > public CTextView(Context context) { > super(context); > > mForward.postRotate(90); > mForward.invert(mReverse); > } > public CTextView(Context context, AttributeSet attrs) { > super(context, attrs); > > mForward.postRotate(90); > mForward.invert(mReverse); > } > public CTextView(Context context, AttributeSet attrs, int defStyle) { > super(context, attrs, defStyle); > > mForward.postRotate(90); > mForward.invert(mReverse); > } > > �...@override > protected void dispatchDraw(Canvas canvas) { > canvas.save(); > canvas.concat(mForward); > canvas.restore(); > > super.dispatchDraw(canvas); > } > > �...@override > public boolean dispatchTouchEvent(MotionEvent event) { > final float[] temp = mTemp; > temp[0] = event.getX(); > temp[1] = event.getY(); > > mReverse.mapPoints(temp); > > event.setLocation(temp[0], temp[1]); > return super.dispatchTouchEvent(event); > } > } > > > -- Jeff Sharkey [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

