gpt4 book ai didi

android - 如何为 android ZBar QrCode 自定义 Scanner 框架?

转载 作者:行者123 更新时间:2023-11-29 01:33:04 25 4
gpt4 key购买 nike

我正在使用这个库,https://github.com/dm77/ZBarScanner

如何自定义扫描仪框架的大小?

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

    if(!isCameraAvailable()) {
// Cancel request if there is no rear-facing camera.
cancelRequest();
return;
}

// Hide the window title.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

mAutoFocusHandler = new Handler();

// Create and configure the ImageScanner;
setupScanner();

// Create a RelativeLayout container that will hold a SurfaceView,
// and set it as the content of our activity.
mPreview = new CameraPreview(this, this, autoFocusCB);
setContentView(mPreview);
}

最佳答案

您可以将所有内容包装在 FrameLayout 中:

    mPreview = new CameraPreview(this, this, autoFocusCB);

//Create a FrameLyout to hold some views
FrameLayout layout = new FrameLayout(this);
FrameLayout.LayoutParams layoutparams=new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
layout.setLayoutParams(layoutparams);

//Example of a toolbar view to add
Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.toolbar_general, layout, false);

layout.addView(mPreview);//Add your CameraPreview
layout.addView(bar);//<----Add the example toolbar
//layout.addView(imageOverlay1);//<----This is where you'll add more views
//layout.addView(imageOverlay2);
setContentView(layout);

希望这对您有所帮助。

关于android - 如何为 android ZBar QrCode 自定义 Scanner 框架?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30180680/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com