Customize Camera View for Android using zbar

后端 未结 3 1304
孤城傲影
孤城傲影 2021-01-01 00:45

I am new in android development. My app should activate the camera to scan a QR code and decode it to a string. This works fine, but I have one more requirement: to present

3条回答
  •  难免孤独
    2021-01-01 01:11

    I think it's easier then you thought:

    In the example code provided by the ZBar guy there are those two lines in the onCreate() method:

    FrameLayout preview = (FrameLayout) findViewById(R.id.cameraPreview);
    preview.addView(mPreview);
    

    which are responsible for adding the "preview view" to the camerPreview Layout.

    Find the mentioned lines in your code, create a new ImageView and also add it to the preview-Layout like this:

    ImageView v = new ImageView(this);
    v.setImageResource(R.drawable.icon);
    preview.addView(v);
    

    Adjust the size and the position of your view v and you are done!

提交回复
热议问题