【问题标题】:How to programmatically change SurfaceView orientation如何以编程方式更改 SurfaceView 方向
【发布时间】:2015-05-23 19:23:25
【问题描述】:

我们需要我们的 android 应用程序支持 Android V2.3 到 V5。我们在 LinearLayout 中渲染 Surface 视图。我们的 Activity 被锁定为纵向。

我们希望以编程方式旋转 SurfaceView,其效果与从纵向变为横向相同。 SurfaceView 是在代码中动态创建并添加到 xml 中定义的 LinearLayout 中的。我们希望保持其他视图相同,这就是我们需要修复 Activity 方向的原因。我们该怎么做?

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    编辑

    无论您在哪里使用相机,请将方向设置为 90 度:

      mCamera = Camera.open();
      mCamera.setDisplayOrientation(90);
    

    【讨论】:

    • SurfaceView 不旋转
    • 嗨,这不是相机表面视图,我有旋转问题。它是从远程端渲染视频的表面视图
    • RotateAnimation rotate= new RotateAnimation(0.0f, 90.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);旋转.setFillAfter(true); remoteSurface.setAnimation(rotate);
    • 您是否尝试在布局 xml 中的表面视图上添加旋转属性?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    • 2020-12-21
    相关资源
    最近更新 更多