Cameraview: Handling rotation

Created on 16 Jan 2018  路  8Comments  路  Source: natario1/CameraView

As the title says, the view is taking to long to be displayed. When the activity is created/rotated it takes time to load resulting in a white screen (background) to be displayed till cameraView is loaded.

Most helpful comment

You must use both lines!

All 8 comments

It's much better if you don't recreate your camera activity for rotations. This is basic Android stuff, just Google it 馃檪

The loading time is needed to connect to the hardware, allocate buffers etc.

@natario1 But when I disable screen orientation by adding this to my Activity in the Manifest android:configChanges="keyboardHidden|orientation|screenSize" the camera orientation is wrong when I rotate the device.

With this flag the preview won't change, like every camera app does. Rotating the device will have no effect and that's generally good

@natario1 but the preview does change even if I use that flag. The only way I get to lock the orientation is to call android:screenOrientation="portrait" but how will I the rotate the buttons if the screen is locked to portrait

Using button.setRotation() and the orientation callback in the CameraListener

@natario1 android:configChanges="keyboardHidden|orientation|screenSize" still doesn't work for me, the screen still rotates, the Activity is not recreated but CameraView still rotates (in the wrong orientation) and if I set android:screenOrientation="portrait" then rotation is not picked up in CameraListner callback

You must use both lines!

Haaa! I got it working, thank you for taking the time to help me and creating a AWSOME library!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arsonistAnt picture arsonistAnt  路  9Comments

g-rabah picture g-rabah  路  11Comments

OLDdriver2 picture OLDdriver2  路  4Comments

xuanxws picture xuanxws  路  4Comments

therealshabi picture therealshabi  路  10Comments