Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing android.view.SurfaceView with a camera on part of the screen
    primarykey
    data
    text
    <p>I trying to put together an Android app that will take a picture and process it in some way. I'd like the layout to be similar to Google Goggles. Meaning, camera preview on the top, and some controls on the bottom using portrait orientation.</p> <p>I've built a first version using code sample from <a href="http://www.androidph.com/2008/11/camera-capture.html" rel="noreferrer">here</a>. This works, but I want to add a button on the bottom.</p> <p>I've modified my main.xml to look as follows (based on comments from this post):</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;android.view.SurfaceView android:id="@+id/preview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentTop="true" /&gt; &lt;Button android:id="@+id/snap" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Snap" android:layout_alignParentBottom="true" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>But when I run this code I get the following exception:</p> <pre><code>E/AndroidRuntime( 199): Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime( 199): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.beerometer/com.beerometer.ImageCapture}: android.view.InflateException: Binary XML file line #6: Error inflating class Android.view.SurfaceView E/AndroidRuntime( 199): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) E/AndroidRuntime( 199): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) E/AndroidRuntime( 199): at android.app.ActivityThread.access$2200(ActivityThread.java:119) E/AndroidRuntime( 199): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) E/AndroidRuntime( 199): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 199): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 199): at android.app.ActivityThread.main(ActivityThread.java:4363) E/AndroidRuntime( 199): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 199): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 199): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) E/AndroidRuntime( 199): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) E/AndroidRuntime( 199): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 199): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class Android.view.SurfaceView E/AndroidRuntime( 199): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576) E/AndroidRuntime( 199): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618) E/AndroidRuntime( 199): at android.view.LayoutInflater.inflate(LayoutInflater.java:407) E/AndroidRuntime( 199): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) E/AndroidRuntime( 199): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) E/AndroidRuntime( 199): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) E/AndroidRuntime( 199): at android.app.Activity.setContentView(Activity.java:1622) E/AndroidRuntime( 199): at com.beerometer.ImageCapture.onCreate(ImageCapture.java:37) E/AndroidRuntime( 199): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) E/AndroidRuntime( 199): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) E/AndroidRuntime( 199): ... 11 more E/AndroidRuntime( 199): Caused by: java.lang.ClassNotFoundException: Android.view.SurfaceView in loader dalvik.system.PathClassLoader@44bfc7b0 E/AndroidRuntime( 199): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) E/AndroidRuntime( 199): at java.lang.ClassLoader.loadClass(ClassLoader.java:573) E/AndroidRuntime( 199): at java.lang.ClassLoader.loadClass(ClassLoader.java:532) E/AndroidRuntime( 199): at android.view.LayoutInflater.createView(LayoutInflater.java:466) E/AndroidRuntime( 199): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565) E/AndroidRuntime( 199): ... 20 more </code></pre> <p>When I replace the SurfaceView above with something else, e.g. a TextView, that it displays, but in landscape.</p> <p>How can I get a camera preview on part of the screen using portrait view?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload