小编VIG*_*GAN的帖子

如何在Surfaceview中将Android相机更改为肖像?

我正在编写一个Android平板电脑,我希望我的应用程序使用surfaceView相机预览的纵向视图.默认情况下它是横向的,我尝试使用以下代码旋转到纵向视图:

public void surfaceCreated(SurfaceHolder holder){
  // The Surface has been created, acquire the camera and tell it where to draw.
  mCamera = Camera.open();
  Parameters params = mCamera.getParameters();
  // If we aren't landscape (the default), tell the camera we want portrait mode
  if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE){
    params.set("orientation", "portrait"); // "landscape"
    // And Rotate the final picture if possible
    // This works on 2.0 and higher only
    //params.setRotation(90);
    // Use reflection to see if it exists and to call it …
Run Code Online (Sandbox Code Playgroud)

java android surfaceview android-camera

5
推荐指数
1
解决办法
5034
查看次数

标签 统计

android ×1

android-camera ×1

java ×1

surfaceview ×1