【发布时间】:2015-07-24 10:43:17
【问题描述】:
嗨,我想做这样的事情
当用户按下旋转图标时,包含在框中的文本应逐渐旋转并使用缩放图标,文本应调整大小。
现在我正在使用此代码将 textview 移动到屏幕上的任何位置
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;
}
它工作正常。 长按 textview 我想显示带有旋转和缩放图标的布局。 我的问题是,
How to create this type of layout for textview and do rotate and scale accordingly?
我见过很多使用矩阵进行旋转和缩放的代码,例如 http://judepereira.com/blog/multi-touch-in-android-translate-scale-and-rotate/
但是这里不知道怎么用。
【问题讨论】:
-
你有没有发现什么有用的东西?如果是,请在此处发布您的答案。
-
@n1m1 如果您有解决方案,请发布答案
标签: android rotation scaletransform