1

Hi I want to do something like this

image

When user presses rotate icon, text contained in box should gradually rotate and using scale icon, text should be resized.

Right now I am using this code for moving the textview everywhere on the screen

 private int _xDelta;
private int _yDelta;

@Override
public boolean onTouch(View view, MotionEvent event) {


    final int X = (int) event.getRawX();
    final int Y = (int) event.getRawY();
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) view.getLayoutParams();
            _xDelta = X - lParams.leftMargin;
            _yDelta = Y - lParams.topMargin;
            break;
        case MotionEvent.ACTION_UP:
            break;
        case MotionEvent.ACTION_POINTER_DOWN:
            break;
        case MotionEvent.ACTION_POINTER_UP:
            break;
        case MotionEvent.ACTION_MOVE:
            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams();
            layoutParams.leftMargin = X - _xDelta;
            layoutParams.topMargin = Y - _yDelta;
            layoutParams.rightMargin = -250;
            layoutParams.bottomMargin = -250;
            view.setLayoutParams(layoutParams);
            break;
    }
    elementslayout.invalidate();
    return true;
}

It is working fine. On long press of textview I want to show the layout with rotate and scale icon. My question is,

 How to create this type of layout for textview and do rotate and scale accordingly?

I have seen many codes for rotate and scale using matrix like http://judepereira.com/blog/multi-touch-in-android-translate-scale-and-rotate/

But don't know how to use it here.

n1m1
  • 869
  • 1
  • 9
  • 20

1 Answers1

-1

I also want to do the same thing, Rotate,Scale as well as move textview all together. I found a link for text rotation here.

Android Two finger rotation

This works totally fine for the text rotation. You just need to add

txt.setRotation(-angle);

In the onRotation Method. May be that helps you.

Community
  • 1
  • 1
Ashwani Kumar
  • 1,402
  • 1
  • 19
  • 26