2

I have used surfaceview (Android 2.2 and above) in that if i make following code in AndroidManifest.xml the result would be fine

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

but if i use below code the camera view is not displaying

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

The picture with landscape mode which working fine is

enter image description here

same picture if i use in portrait mode will become

enter image description here

can anybody suggest me why this is happening

the xml file is

     <?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

if it is in portrait mode i am getting error like below

       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

in landscape it's working fine

Siddhpura Amit
  • 14,534
  • 16
  • 91
  • 150

1 Answers1

0
  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  

It will take some time but you have lot of examples and tutorials

Lochana Ragupathy
  • 4,320
  • 2
  • 25
  • 36