바코드를 가운데로 정렬하고자 하는데 bg가 가운데로 오는 이유가 멀까요?

 

 

aa.JPG

 

일부 소스입니다.

private Drawable image;
image = this.getResources().getDrawable(R.id.BarcodeView); 
@Override
 protected void onDraw(Canvas canvas) {
  int viewWidth = this.getWidth();
     int viewHeight = this.getHeight();
     int imageWidth = image.getIntrinsicWidth();
     int imageHeight = image.getIntrinsicHeight();
     int x = viewWidth / 2 - imageWidth / 2;
     int y = viewHeight / 2 - imageHeight / 2;
     image.setBounds(x, y, x + imageWidth, y + imageHeight);
     image.draw(canvas);
     
  super.onDraw(canvas);
  try {
   testCODE128(canvas);
  } catch (Exception e) {
   e.printStackTrace();
  }
 } 

 

xml

 <kr.dkmedia.BarcodeView
                    android:id="@+id/BarcodeView"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center" />


관련 참고 사이트 :

http://bspop.tistory.com/entry/CustomView-%EA%B7%B8%EB%A6%BC-%EC%A0%95%EA%B0%80%EC%9A%B4%EB%8D%B0-%EC%B6%9C%EB%A0%A5

 

private Drawable image;
image = this.getResources().getDrawable(R.id.BarcodeView); 

아무래도 이부분이 잘못된거 같은데..도무지 모르겠어요..
관련참고사이트에서처럼  R.drawable.BarcodeView하면 빨간색 에러가 나와요..

모가 잘못된건가요?

 

제껏은 예제처럼 뷰를 drawable로 호출하지 못하는 이유가 몬가요?