Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding Menu to ZXings barcodescanner, and squeezing the surfaceview
    primarykey
    data
    text
    <p>Zxings barscanner app, I have implemented it, as a library project, and it works. </p> <p>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.)</p> <p>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 :-/</p> <p><strong>Short</strong>: 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.</p> <p>Can anyone help me?</p> <p>layout XML (with the menu inserted, and unnecessary removed):</p> <p></p> <pre><code>&lt;SurfaceView android:id="@+id/preview_view" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;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" /&gt; &lt;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" &gt; &lt;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"/&gt; &lt;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" /&gt; &lt;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" /&gt; &lt;/LinearLayout&gt; &lt;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" &gt; **removed** &lt;/LinearLayout&gt; **removed** </code></pre> <p></p> <p>Left picture: Is how the view is now and item placed where it is not being recognized.</p> <p>Right picture: Item placed where it is recognized (How I check that target area is not changed):</p> <p><img src="https://i.stack.imgur.com/12yBP.png" alt="Image of view"> <img src="https://i.stack.imgur.com/ioaUd.png" alt="result found"></p> <p>Changes to CameraManager (squeezing of the viewfinder):</p> <pre><code>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 &lt; MIN_FRAME_WIDTH) { width = MIN_FRAME_WIDTH; } else if (width &gt; MAX_FRAME_WIDTH) { width = MAX_FRAME_WIDTH; } int height = screenResolution.y * 3 / 4; if (height &lt; MIN_FRAME_HEIGHT) { height = MIN_FRAME_HEIGHT; } else if (height &gt; 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; } </code></pre> <p>Now I have taken it all out into a small project which can be found <a href="https://rapidshare.com/files/2696702205/GCMtest.zip" rel="nofollow noreferrer">here</a> (problem fixed, were missing a lib) oct 18 10:14 CET</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.
    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