问题
I use the camera2 api to show a camerapreview, and i lock the screen orientation on lanscape, my problem is that i want to rotate the textureview to display the correct camerapreview, when i rotate it using the method setRotation, it becomes smaller. I search on stack but all solutions are relative to camera(first api) so is there a solution to rotate the textureView.
回答1:
You can add a rotation to the TextureView's matrix. For an example, see Grafika's "play movie activity", which sends the output of a video decoder to a TextureView (same basic principles as Camera preview).
If you look at adjustAspectRatio() you can see it adjusting the position (translation) and scale of the output to match the video's aspect ratio. There's also a commented out postRotate()
call that would rotate the output 10 degrees.
Note this is rotating the video frame within the View, not the View itself.
来源:https://stackoverflow.com/questions/31650446/how-to-rotate-textureview-to-show-a-camerapreview