2011-05-15 5 views
0

ShapeDrawable 객체를 TableLayout 셀 안에 넣으려고합니다. 문서 here에 의해 제안 나는 사용자 정의보기 mCustomView를 만든 다음ShapeDrawable 및 TableLayout

mRow.addView(mCustomView) 
mTableLayout.addView(mRow) 

모두를 수행하여 TableLayout을에보기를 추가, 아니 오류가 잘 작동하지 않습니다하지만 모양이 전혀 표시되지 않습니다. 내 당김을 만들 수

코드는 좀 더 파고 후

icon = new ShapeDrawable(new ArcShape(0, 360)); 
icon.setBounds(0, 0, 20, 20); 
icon.getPaint().setColor(parseColor); 

답변

1

이며 연구하는 것은 solution이 최고는 ImageView 생성자에 ShapeDrawable 개체를 전달하고 테이블 행이보기를 추가하는 것으로 나타났다 이 같은 것을 가지고

ShapeDrawable icon = new ShapeDrawable(new ArcShape(0, 360)); 
icon.getPaint().setColor(parseColor); 
icon.setIntrinsicHeight(30); 
icon.setIntrinsicWidth(30); 
ImageView iv = new ImageView(this); 
iv.setImageDrawable(icon); 
mRow.addView(iv); 
mTableLayout.addView(mRow) 

이 솔루션은 커스텀 View 클래스를 제거하는 장점이 있습니다.