2015-07-21 55 views
0

好了,所以,我希望讓這樣的事情zbar和添加浮動視圖

public class BarKodScreen extends AppCompatActivity implements ZBarScannerView.ResultHandler { 

private ZBarScannerView mView; 
private BarcodeFormat barcodeFormatEAN13, barcodeFormatEAN8; 
private List<BarcodeFormat> listaZaFormat = new ArrayList<BarcodeFormat>(); 
private ImageView img; 
private LinearLayout lejout; 
private View kamera; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_barkod); 
    mView = new ZBarScannerView(this); 
    lejout = (LinearLayout) findViewById(R.id.cameraPreview); 
    img = (ImageView) findViewById(R.id.cameraImageView); 
    kamera = (View) findViewById(R.id.zaKameru); 
    kamera = mView; 
    lejout.addView(kamera); 
    lejout.addView(kamera); 
    lejout.removeView(img); 
    lejout.addView(img); 


    barcodeFormatEAN13 = BarcodeFormat.EAN13; 
    barcodeFormatEAN8 = BarcodeFormat.EAN8; 
    listaZaFormat.add(barcodeFormatEAN13); 
    listaZaFormat.add(barcodeFormatEAN8); 

    mView.setFormats(listaZaFormat); 
} 


@Override 
public void onResume() { 
    super.onResume(); 
    mView.setResultHandler(this); // Register ourselves as a handler for scan results. 
    mView.startCamera();   // Start camera on resume 
} 

@Override 
public void onPause() { 
    super.onPause(); 
    mView.stopCamera();   // Stop camera on pause 
} 

@Override 
public void handleResult(Result rawResult) { 
    // Do something with the result here 
    Log.v("GetCOntent", rawResult.getContents()); // Prints scan results 
    barKodZahtev(rawResult.getContents()); 
} 
} 

和我的XML是:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/cameraPreview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <View 
     android:id="@+id/zaKameru" 
     android:layout_width="match_parent" 
     android:layout_height="150dp"/> 

    <ImageView 
     android:id="@+id/cameraImageView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:alpha="0.6" 
     android:src="@drawable/share" /> 


</LinearLayout> 

我不明白的是如何添加圖像(截圖中的文本)作爲我的zbarscannerView的子視圖。

回答

0

看看他們在github上的倉庫,他們有東西在那裏。