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 8041987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:24:52+00:00 2026-06-05T04:24:52+00:00

im new in android programming.. i have a problem here. i wanna make an

  • 0

im new in android programming..
i have a problem here.

i wanna make an application that draw overlay on top real view from camera.
i use surface view for hold image from camera.

here my XML for my main activity:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
        <SurfaceView
            android:id="@+id/preview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
        />
        <com.openit.razer.overlayPreview
            android:id="@+id/overlayprev"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
        <com.openit.razer.overlayImage
            android:id="@+id/overlayimg"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
</RelativeLayout>

and this is my main activity class:
p

ublic void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ar);

        overPrev = (overlayPreview)findViewById(R.id.overlayprev);
        overImg = (overlayImage)findViewById(R.id.overlayimg);

        overImg.setZOrderOnTop(true);
        overImg.getHolder().setFormat(PixelFormat.TRANSPARENT);


        preview=(SurfaceView)findViewById(R.id.preview);
        previewHolder=preview.getHolder();
        previewHolder.addCallback(surfaceCallback);
        previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
SurfaceHolder.Callback surfaceCallback=new SurfaceHolder.Callback() {
        public void surfaceCreated(SurfaceHolder holder) {
          try {
            camera.setPreviewDisplay(previewHolder);
          }
          catch (Throwable t) {
            Log.e("PreviewDemo-surfaceCallback",
                  "Exception in setPreviewDisplay()", t);
            Toast
              .makeText(ARrazerNav.this, t.getMessage(), Toast.LENGTH_LONG)
              .show();
          }
        }

        public void surfaceChanged(SurfaceHolder holder,
                                   int format, int width,
                                   int height) {

          Camera.Parameters parameters=camera.getParameters();
          //Camera.Size size=getBestPreviewSize(width, height,
                                             // parameters);
          List<Camera.Size> sizes = parameters.getSupportedPreviewSizes();
          Camera.Size selected = sizes.get(0);
          parameters.setPreviewSize(selected.width, selected.height);
          camera.setParameters(parameters);
          if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){
              camera.setDisplayOrientation(90);
          }
          else{
              camera.setDisplayOrientation(0);
          }
          //camera.setDisplayOrientation(90);
          //camera.setDisplayOrientation(0);
          camera.startPreview();
        }

        public void surfaceDestroyed(SurfaceHolder holder) {
          // no-op
        }
      };

but i got errror

FATAL EXCEPTION:main
...
...
...
caused by: android.view.InflateException: Binary XML file line #10: Error inflating class blablabla

could u help me to solve my problems. it was a 3 days im stuck in this problem.

and whats the best method for implementing Camera with SurfaceView and overlay image on top of it?

thanks in advance

  • 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-06-05T04:24:55+00:00Added an answer on June 5, 2026 at 4:24 am

    You should be using a FrameLayout to place views on top of other views. SurfaceView first, then the views you want on top of it.

    I actually did this myself, putting an image over a camera preview. I used a FrameLayout with a SurfaceView and an ImageView on top of it. Worked pretty well.

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

Sidebar

Related Questions

I'm abit new to programming Android App's, however I have come across a problem,
I'm new to Android & Java programming but have been programming in .NET for
I am new to Android and Java programming. I have a class which implements
I'm relatively new to Android programming, and am having a problem with inflation. I'm
I'm new in Android Programming. I'm trying to write an app that uses USB
I have a problem programming with Android SDK 1.6. I'm doing the same things
I'm new to android programming and i have a question I'm developing an alarm
I am very new to Android programming, and I have read everywhere and I
I'm new to Android programming and I am making a game. My problem is
I am programming an Android application and have a curious issue. My application has

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.