繁体   English   中英

相机无法在人像方向android 2.2及更高版本中工作

[英]camera is not working in portrait orientation android 2.2 and above

我使用了Surfaceview(Android 2.2及更高版本),因为如果我在AndroidManifest.xml中执行以下代码,结果会很好

   <activity
        android:name="com.custom.camera.CustomCamera"
        android:screenOrientation="landscape" >
    </activity>

但是,如果我使用下面的代码,则不会显示相机视图

     <activity
        android:name="com.custom.camera.CustomCamera"
        android:screenOrientation="portrait" >
    </activity>

风景模式下的图片效果很好

在此处输入图片说明

如果我在人像模式下使用同一张图片

在此处输入图片说明

有人可以建议我为什么会这样吗

xml文件是

     <?xml version="1.0" encoding="utf-8"?>

<FrameLayout
    android:id="@+id/mPreview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

<FrameLayout
    android:id="@+id/overlay_container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:visibility="visible" >

    <Button
        android:id="@+id/mTakePicture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Take Picture" />

    <ImageView
        android:id="@+id/mFrontView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp" />
</FrameLayout>

         LOGCAT ISSUE

如果它是纵向模式,我会收到如下错误

       12-16 15:43:09.297: E/Camera(7104): Error 1
       12-16 15:43:15.297: E/Camera(7104): Error 1
       12-16 15:43:21.307: E/Camera(7104): Error 1
       12-16 15:43:27.337: E/Camera(7104): Error 1

在风景上很好

  1)You have to make your own custom view with all your logics and design in a separate class which extends View

  2) The SurfaceView must be placed inside a Frame or RelativeLayout 

  3) Finally your custom view must be specified in your layout xml as a child  

这需要一些时间,但是您有很多示例和教程

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM