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

  • SEARCH
  • Home
  • 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 8718683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:36:18+00:00 2026-06-13T06:36:18+00:00

Zxings barscanner app, I have implemented it, as a library project, and it works.

  • 0

Zxings barscanner app, I have implemented it, as a library project, and it works.

Now I am to change the size of the field(Target Field) which is scanned (done as well).
(though the scanning area remains the same, this didn’t matter since focus was still in center.)

But then I needed to insert a menu in the left side. This forces me to change the Target Field, and this is were it starts crashing, if I change the size of the surfaceview or viewFinderView and if I wrap it in a relative view, it still decodes only the center(of cause). I just can’t figure out a solution :-/

Short: I am able to change the area where the scan should be happening but this is only visible. The actual scanned area is still the center of the complete screen and not the center of the moved visible scan area.

Can anyone help me?

layout XML (with the menu inserted, and unnecessary removed):

<SurfaceView
    android:id="@+id/preview_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

<com.google.zxing.client.android.ViewfinderView
    android:layout_marginLeft="120dip"
    android:id="@+id/viewfinder_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/transparent" />

<LinearLayout
    android:id="@+id/buttonPanel"
    android:layout_width="120dip"
    android:layout_height="fill_parent"
    android:background="#000"
    android:orientation="vertical"
    android:paddingBottom="15dip"
    android:paddingTop="15dip" >

    <TextView 
        android:id="@+id/menuText"
        android:layout_weight="1"
        android:layout_width="90dip"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dip"
        android:text="@string/menu_title"/>
    <ImageView
        android:id="@+id/d1Button"
        android:layout_width="90dip"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dip"
        android:layout_weight="2"
        android:onClick="scanner1d"
        android:src="@drawable/d1image" />

    <ImageView
        android:id="@+id/d2Button"
        android:layout_width="90dip"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dip"
        android:layout_weight="2"
        android:onClick="scanner2d"
        android:src="@drawable/d2image" />
</LinearLayout>

<LinearLayout
    android:id="@+id/result_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/result_view"
    android:orientation="vertical"
    android:padding="4dip"
    android:visibility="gone" >

       **removed**
</LinearLayout>
   **removed**

Left picture: Is how the view is now and item placed where it is not being recognized.

Right picture: Item placed where it is recognized (How I check that target area is not changed):

Image of view
result found

Changes to CameraManager (squeezing of the viewfinder):

public Rect getFramingRect() {
    // added
    int menuSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 
                    (float) 120, context.getResources().getDisplayMetrics());
    // end of added

    Point screenResolution = configManager.getScreenResolution();
    if (framingRect == null) {
        if (camera == null) {
            return null;
        }
        int width = screenResolution.x * 3 / 4;
        if (width < MIN_FRAME_WIDTH) {
            width = MIN_FRAME_WIDTH;
        } else if (width > MAX_FRAME_WIDTH) {
            width = MAX_FRAME_WIDTH;
        }
        int height = screenResolution.y * 3 / 4;
        if (height < MIN_FRAME_HEIGHT) {
            height = MIN_FRAME_HEIGHT;
        } else if (height > MAX_FRAME_HEIGHT) {
            height = MAX_FRAME_HEIGHT;
        }


        // added menu size for calculation

        int leftOffset = ((screenResolution.x -menuSize - width) / 2);
        int topOffset = (screenResolution.y - height) / 2;
        framingRect = new Rect(leftOffset, topOffset, leftOffset + width,
                topOffset + height);
        Log.d(TAG, "Calculated framing rect: " + framingRect);
    }
    return framingRect;
}

Now I have taken it all out into a small project which can be found
here (problem fixed, were missing a lib) oct 18 10:14 CET

  • 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-13T06:36:20+00:00Added an answer on June 13, 2026 at 6:36 am

    If you squeeze both the surfaceview together with the viewfinderview, it will actually work.

    Though you have to take into consideration that the image is squeezed, so the target rectangle has to be that much smaller.

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

Sidebar

Related Questions

I have the zxing library imported into my project and the scanner works like
I am using zxing library for my app which has barcode functionality. My App
I have an app in which i use zxing barcode scanner to scan qr
I have downloaded the Zxing barcode reader android project. Now opened this source in
I have integrated zxing library to my app to scan QR code. As i
I have Integrated ZXing code into my own app and I have commented the
I have integrated Zxing library in my Android application, and it is Perfectly working,
I want to integrate the zxing barcode scanner into my app. I have followed
I am trying to integrate zxing in my already existing iPhone app. I have
I am using zxing library, where I have built ZXing Android using Eclipse and

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.