How can I make a SurfaceView larger than the screen?

前端 未结 4 929
清酒与你
清酒与你 2021-01-02 00:25

I would like to effectively make a simple digital zoom for the camera preview, so I thought I would simply resize my SurfaceView to be larger than the screen. Other questio

4条回答
  •  隐瞒了意图╮
    2021-01-02 00:57

    Here's my TouchSurfaceView's onMeasure that performs zoom:

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
        {
            int width = MeasureSpec.getSize(widthMeasureSpec);
            int height = MeasureSpec.getSize(heightMeasureSpec);
            setMeasuredDimension((int) (width * scaleFactor), (int) (height * scaleFactor));
        }
    

    This properly zooms in and out depending on scaleFactor.

    I haven't tested this with camera, but it works properly with MediaPlayer (behaving as VideoView).

提交回复
热议问题