
我正在创建一个条形码扫描仪应用程序,我想使用Zxing读取条形码,我的应用程序具有SurfacevIEw并在其中显示相机,但是现在我想从SurfaceVIEw相机中扫描条形码,我使用它的原因是,我在我的布局的表面视图下有两个Edittext,以显示条形码的内容.
我应该如何创建类似的应用程序,主要问题是如何将zxing设置为Surface.
如果有什么办法,我将不胜感激.
布局截图:
解决方法:
使用以下代码自定义zxing布局.
我在这里带了一个用于Zxing Scanner的relativeLayout.
或者,使用以下引用:
> https://github.com/dm77/barcodescanner/issues/67
我的设计如下图所示,如果需要,可以采用FrameLayout.
Xml代码:
<linearLayout androID:orIEntation="vertical" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content"><androID.support.v7.Widget.Toolbar androID:ID="@+ID/toolbaradjustScan" androID:layout_wIDth="match_parent" androID:layout_height="56dp" androID:background="@color/colorPrimary" androID:elevation="6dp" androID:minHeight="56dp" androID:theme="@style/themeOverlay.AppCompat.Dark"> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:orIEntation="horizontal"> <TextVIEw androID:ID="@+ID/TitleToolbar" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_gravity="center" androID:layout_marginleft="15dp" androID:ellipsize="end" androID:layout_weight="1" androID:maxlines="1" androID:textcolor="@color/white" androID:textSize="18dp" /> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:gravity="right" androID:padding="10dp" androID:ID="@+ID/searchAdjustBtn" androID:layout_marginleft="15dp" androID:ellipsize="end" androID:maxlines="1" androID:text="SEARCH " androID:textcolor="@color/white" androID:textSize="13dp" /> </linearLayout></androID.support.v7.Widget.Toolbar> <TextVIEw androID:ID="@+ID/textv" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:background="@color/colorPrimaryDark" androID:gravity="center_horizontal" androID:paddingBottom="10dp" androID:paddingtop="10dp" androID:text="Point at any barcode to scan" androID:textcolor="@color/white" androID:textSize="14sp" androID:textStyle="normal" /><relativeLayout androID:layout_marginBottom="120dp" androID:layout_below="@+ID/textv" androID:ID="@+ID/relative_scan_take_single" androID:layout_wIDth="match_parent" androID:layout_height="match_parent"></relativeLayout></linearLayout><linearLayout androID:layout_alignParentBottom="true" androID:layout_wIDth="match_parent" androID:background="@color/colorPrimaryDark" androID:layout_height="120dp" androID:orIEntation="horizontal"> <button androID:ID="@+ID/doneBtn" androID:layout_wIDth="match_parent" androID:layout_height="80dp" androID:layout_gravity="bottom" androID:text="Done" androID:textAllCaps="true" androID:textcolor="@color/white" androID:textSize="22dp" /></linearLayout>活动代码:(Java)
public class TakeSingleScanActivity extends AppCompatActivity implements ZXingScannerVIEw.ResultHandler { private ZXingScannerVIEw mScannerVIEw; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_take_single_scan); //Scanner mScannerVIEw = new ZXingScannerVIEw(this); relativeLayout rl = (relativeLayout) findVIEwByID(R.ID.relative_scan_take_single); rl.addVIEw(mScannerVIEw); mScannerVIEw.setResultHandler(this); mScannerVIEw.startCamera(); mScannerVIEw.setSoundEffectsEnabled(true); mScannerVIEw.setautoFocus(true); } 总结 以上是内存溢出为你收集整理的Java-通过SurfaceView使用Zxing条形码阅读器全部内容,希望文章能够帮你解决Java-通过SurfaceView使用Zxing条形码阅读器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)