Skip to content Skip to sidebar Skip to footer

How To Display Canvas In Current Activity Image View In Android

public class AndroidBarcodeView extends ImageView { public AndroidBarcodeView(Context context) { super(context); } @Override protected void onDraw(Canvas

Solution 1:

I won't write code for you. This is just an answer on your question:

Find and replace RectF bounds = new RectF(0, 0, 0, 0); with RectF bounds = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());


publicclassAndroidBarcodeViewextendsImageView {
    //...privatestaticvoidtestQRCode(Canvas canvas)throws Exception {
      //...RectFbounds=newRectF(0, 0, canvas.getWidth(), canvas.getHeight());
      barcode.drawBarcode(canvas, bounds);
    }
}

publicclassStudentManinPageextendsActivity {
  //...@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      AndroidBarcodeViewbar_code_view=newAndroidBarcodeView(this);
      bar_code_view.setLayoutParams(newLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

      setContentView(bar_code_view);
      //...
  }
  //...
}

Post a Comment for "How To Display Canvas In Current Activity Image View In Android"