Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:35:59+00:00 2026-06-02T11:35:59+00:00

i made a barcode generator using code128 but when my barcode generate then it

  • 0

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();
    }       
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:36:02+00:00Added an answer on June 2, 2026 at 11:36 am

    If you want to generate bar code for desired information, then use this code

    package com.barcodegeneration.in;
    
    import com.onbarcode.barcode.android.AndroidColor;
    import com.onbarcode.barcode.android.AndroidFont;
    import com.onbarcode.barcode.android.Code128;
    import com.onbarcode.barcode.android.Code39;
    import com.onbarcode.barcode.android.IBarcode;
    
    import android.content.Context;
    import android.graphics.Bitmap;
    import android.graphics.Canvas;
    import android.graphics.RectF;
    import android.graphics.Typeface;
    import android.view.View;
    
    public class MakeBarcode extends View{
    
        public MakeBarcode(Context context) {
    
            super(context);
            System.out.println("im in view class");
            // TODO Auto-generated constructor stub
        }
    public void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);
         try {
            generate_barcode(canvas);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    
    }
    public static void generate_barcode(Canvas canvas)throws Exception {
        Code128 barcode = new Code128();
        barcode.setData("ash");
      //  barcode.setData("ashutosh");
        barcode.setProcessTilde(false);
        System.out.println("i m inside code 39 without static mmm");
        System.out.println("i m inside code 39 mmm");
        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);
    
    
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }       
    }
    
    }
    
    
    please like this post if useful for you.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made the ultimate laugh generator using these rules. Can you implement it in
I made a form using the Qt Designer which has some dockwidgets, these dockwidgets
Made solution change: I am trying to display a html table of data.. In
Hi i made an app barcodescanner using ZXing project.actually i added some code in
I made a page using HTML which have some .jpg files and some .swf
Made a custom obj called Item with some string fields and one float. .h
Made some changes to my Django app's model and used South to migrate them
made a menu out of the following code but the original href in the
I made of subclass of UIView called Bubble using which i want to draw
I made some changes in my master branch and want to bring those upstream.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.