Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Offsetting and styling ViewFinderView #16

Closed
xolan opened this issue Jun 4, 2014 · 4 comments
Closed

Offsetting and styling ViewFinderView #16

xolan opened this issue Jun 4, 2014 · 4 comments

Comments

@xolan
Copy link
Contributor

xolan commented Jun 4, 2014

Is there a way to offset ViewFinderView? It would also be nice to be able to set my own styles/colors for the laser, border etc.

Note: I mean when using as a library as opposed to importing and altering/forking the source myself.

@dm77
Copy link
Owner

dm77 commented Jun 4, 2014

@xolan thanks for request.

For changing colors, in your project's colors.xml you can put the following xml and change the hex colors to whatever you need:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="viewfinder_mask">#60000000</color>
    <color name="viewfinder_laser">#ffcc0000</color>
    <color name="viewfinder_border">#ffafed44</color>
</resources>

As for offsetting the ViewFinderView, right now it is setup exactly in the center of the surfaceview. Can you help me understand how changing the offset is helpful, like what are you trying to accomplish?

@xolan
Copy link
Contributor Author

xolan commented Jun 6, 2014

The changing of colors makes sense now that you mention it.

Essentially I have an Activity with a Fragment containing a TabHost with 3+ tabs. Within one of these tabs I'm using ZBarScannerView with which I'm scanning QR codes. It seems the top most fragment, which has an ActionBar, is pushing the scanner down, and I'd like to re-adjust it so that the "view finder" remains center in terms of mobile display, not center in terms of it's parent view.

I guess I could go over my layout hierarchy to see if I can accomplish the desired look that way.

Thanks for the quick reply though!

@xolan
Copy link
Contributor Author

xolan commented Jun 6, 2014

Here's the issue I'm having. http://imgur.com/5q02oUy

The ViewFinder seems to be centered in relation to the device screen size (but pushed down by the actionbar/tabs) instead of the layout I've added the view to.

Do you have any ideas on how I can fix this?

@dm77
Copy link
Owner

dm77 commented Jun 6, 2014

One way to make the action bar to not push down the camera preview is by overlaying it (http://developer.android.com/training/basics/actionbar/overlaying.html)

The sample app (https://github.com/dm77/barcodescanner/blob/master/zxing/sample/src/main/res/values/styles.xml) uses the overlay actionbar to achieve this.

I will try to change this in a future release so that people are not forced to use the overlay action bar.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants