java如何复制Androids库存摄像头方向更改
我有一台三星Edge,API 24,安卓7.0和一台三星平板电脑,API 24,安卓7.0
如果你不想了解背景故事,请跳过这一块报价部分:
I want to recreate the stock camera and implement it into my app. I'm actually very close to having it finished (using Xamarin.Android + C#), using the Xamarin Version of the Google Camera Sample.
However there are orientation problems left... 180° rotations (landscape -> reverse landspace or vice versa) don't trigger the "SurfaceChanged" event, which is used to set the matrix of the surface to make it display correctly.
I've seen different approaches, one seems stable: Fix the orientation to landscape and handle orientations myself.
查看我的两台设备的库存摄像头,我发现摄像头预览从未移动过一点,只有按钮旋转+活动(方向改变时状态栏移动到顶部) 如何实现这种行为
一个抽象的想法,或者Java或C语言的代码片段就好了
# 1 楼答案
在开始时修复活动方向(例如,在
onResume
方法内部):在
AndroidManifest.xml
中指定希望活动侦听方向更改:然后处理活动中的方向变化: