0
我做了一個條形碼生成器使用code128,但是當我的條形碼生成,然後它不會顯示在我的佈局。所以PLZ建議我一些解決方案,如何在我的佈局顯示生成的條形碼 輸入代碼在這裏使條碼生成器在android
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
l1=(LinearLayout) findViewById(R.id.linear);
Code128 barcode = new Code128();
Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
canvas=new Canvas(b);
barcode.setData("11223344556688777");
barcode.setProcessTilde(false);
barcode.setUom(IBarcode.UOM_PIXEL);
barcode.setX(1f);
barcode.setY(75f);
barcode.setLeftMargin(10f);
barcode.setRightMargin(10f);
barcode.setTopMargin(10f);
barcode.setBottomMargin(10f);
barcode.setResolution(72);
barcode.setShowText(true);
barcode.setTextFont(new AndroidFont("Arial", Typeface.NORMAL, 12));
barcode.setTextMargin(6);
barcode.setTextColor(AndroidColor.black);
barcode.setBackColor(AndroidColor.white);
RectF bounds = new RectF(30, 30, 0, 0);
try {
barcode.drawBarcode(canvas, bounds);
l1.draw(canvas);
l1.addView(t1);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}