Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 684253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:47:46+00:00 2026-05-14T01:47:46+00:00

I trying to put together an Android app that will take a picture and

  • 0

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.

I’ve built a first version using code sample from here. This works, but I want to add a button on the bottom.

I’ve modified my main.xml to look as follows (based on comments from this post):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent" >

      <android.view.SurfaceView android:id="@+id/preview"
                              android:layout_width="fill_parent"
                              android:layout_height="fill_parent"
                              android:layout_alignParentTop="true" />

    <Button android:id="@+id/snap" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="Snap"
            android:layout_alignParentBottom="true" />

</RelativeLayout>

But when I run this code I get the following exception:

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

When I replace the SurfaceView above with something else, e.g. a TextView, that it displays, but in landscape.

How can I get a camera preview on part of the screen using portrait view?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:47:47+00:00Added an answer on May 14, 2026 at 1:47 am

    First, your layout probably won’t give you what you want. Consider using a RelativeLayout, with the Button anchored to the bottom, and the SurfaceView anchored to the top of the screen and the top of the Button.

    Also, you have a duplicate xmlns:android="http://schemas.android.com/apk/res/android" on your SurfaceView that you don’t need. The one on your root element will suffice.

    In terms of your exception, there may be more detail in your stack trace that you are missing, explaining why startPreview() failed. Look for a “Caused by” or other line mid-way through the stack trace. If you can’t identify it, edit your question and paste in the entire stack trace (and ping me via a comment on this answer, since I won’t know about the edit otherwise).

    You might also experiment with this book example as another Camera preview app, to see if there’s something about how I approach the problem that works better for your circumstance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to put together some Javascript form validation to check that all fields
Having some issues with this search engine I am trying to put together. I'll
I am trying to learn or put together the bits and pieces that I
I'm a frontend dev with no windows phone dev experience trying to put together
I am trying to put together an SQL database but don't really know how
I am trying to put together a html email for a client. I'm used
Using PostgreSQL 8.4, I'm trying to put together the following query: SELECT (field_a +
I'm trying to use the Chilkat encryption library in SQL Server 2008 via a
So I've been trying to solve this problem for a matter of hours now.
class GameController < ApplicationController def index @games = Game.all respond_to do |format| format.html end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.