Reputation: 199
I have an image editing android application in which I am using a custom EditTextView
which is placed on an ImageView
.This image view is also a custom view which can rotate, zoom, drag, etc... Now, I want to drag this EditText
and to rotate when click on a button. This is my custom EditTextView
:
public class TemplateTextView extends EditText {
private static float angle;
// We can be in one of these 3 states
private int mode = NONE;
// Remember some things for zooming
PointF start = new PointF();
PointF mid = new PointF();
PointF startMargins = new PointF();
float oldDist = 1f;
/**
* Constructor for TemplateTextView
*
* @param context
* @param attrs
* @param defStyle
*/
public TemplateTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// mWindowManager = (WindowManager)
// context.getSystemService(Context.WINDOW_SERVICE);
}
/**
* Constructor for TemplateTextView
*
* @param context
* @param attrs
*/
public TemplateTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
/**
* Constructor for TemplateTextView
*
* @param context
*/
public TemplateTextView(Context context) {
this(context, null);
}
}
The EdittextView
is dragged when long click on it. How can I rotate and drag this view?
Upvotes: 4
Views: 733
Reputation: 662
For rotating, you can simply do that in the onDraw-Method of your TemplateTextView:
@Override
protected void onDraw(Canvas canvas) {
canvas.rotate(angle, canvas.getClipBounds().right/2, canvas.getClipBounds().bottom/2);
super.onDraw(canvas);
}
Cheers, Dude
Upvotes: 1