如何使textview移动,旋转和放大android

时间:2015-07-07 06:38:10

标签: android textview

我正在尝试使用缩放,旋转和移动属性在图像上添加文本。我通过将文本转换为图像部分实现了这一点,但我想通过仅使用textview来做同样的事情。

1 个答案:

答案 0 :(得分:0)

Try This

    public class simpleOnScaleGestureListener extends SimpleOnScaleGestureListener {
        @Override
        public boolean onScale(ScaleGestureDetector detector) {
            float size = codedText.getTextSize();
            float factor = detector.getScaleFactor();
            int increase = 0;
            if(factor > 1.0f)
                increase = 2;
            else if(factor < 1.0f)
                increase = -2;

            size += increase;


            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);            
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //remembering the favourable text size
            Editor edit = sp.edit();
            edit.putFloat("TXTSIZE", size);
            edit.commit();
            return true;
        }
    }