KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I found out that setPivotX (also setPivotY ) works strange in Android. If you set pivot when view's scale is set to 1.00f nothing happens (just pivot changes). But if the scale isn't equal 1.0f (e.g. setScaleX(0.9f) ) and you set the pivot the view moves relatively(?) to the new pivot. Isn't it strange? I know that horizontal and vertical positions (translations) are NOT related to the pivot value, but why the view moves with scale factor other than 1.0f? Please check this out with and without the scaling part. public class ScaleView extends View { private final ScaleGestureDetector mScaleGestureDetector; public ScaleView(Context context, AttributeSet attrs) { super(context, attrs); //setScaleX(0.9f); //setScaleY(0.9f); mScaleGestureDetector = new ScaleGestureDetector(context, new ScaleGestureDetector.OnScaleGestureListener() { @Override public void onScaleEnd(ScaleGestureDetector detector) { // does nothing intentionally } @Override public boolean onScaleBegin(ScaleGestureDetector detector) { setPivotX(detector.getFocusX()); setPivotY(detector.getFocusY()); return true; } @Override public boolean onScale(ScaleGestureDetector detector) { return false; } }); } @Override public boolean onTouchEvent(MotionEvent event) { mScaleGestureDetector.onTouchEvent(event); return super.onTouchEvent(event); } } How do I set the same position of the view, which was before the pivot changed?
Tags (comma-separated)
Save Edits
Cancel