i made a barcode generator using code128 but when my barcode generate then it wont display in my layout. so plz suggest me some solution that how to display generated barcode in my layout
enter code here
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();
}
}
No comments:
Post a Comment