난 당신이 뷰를 사용하는 대신이를 그리는 사용자 지정보기를 만들어보십시오 수있는 생각이있어.
새 클래스에서 View 클래스를 확장하고 onDraw 메서드를 재정의합니다. 사용자 지정 컨트롤에
//variables
Paint paint[]; //Set up these paints with the colors you need
int rowWidth, int colHeight;
void onDraw(Canvas c){
for(int i=0;i<noOfRows;i++){
for(int j=0;j<noOfColumns;j++){
if(cellRequired(i,j)){
//cellRequired will be whatever logic you have to check if cell is required
int rectHeight=colHeight; //Now the Rect Height changes whether the cell
// below is in use or not.
for(int k=i;k<noOfRows;k++){
//This loop will run through the rows and see if merging is required
if(cellRequired(i,k))
rectHeight+=colHeight; //Merge Cell
else
break; //If not required at any point break loop
}
//Draw Rectangle background
c.drawRect(i*rowWidth +i, j*colHeight +j, rowWidth, rectHeight, backPaint);
//Draw Text
canvas.drawText("Text",i*rowWidth +i, j*colHeight +j, paint[requiredPaint]);
//I added the plus i and plus j so there'd be a gap in the rectangles
// Then it will be a border
}
}
}
}
안드로이드 문서는
Android: Tutorial on Custom View creation
어떻게 정의를 만드는
이
http://www.droidnova.com/playing-with-graphics-in-android-part-i,147.html
이를 통해 다음 위의 코드를 통해 이동 위 유사한 볼 . 다행히 그것을 구현하는 방법을 보여 주길 바랍니다.
새 창으로 표시 하시겠습니까? 이것은 약간 모호합니다. 테이블을 대화 상자에 넣으시겠습니까? 레이아웃에서? 런타임에 프로그래밍 방식으로 생성됩니까? 테이블을 동적으로 작성해야한다고 계산 했으므로 작성 했습니까? @CarlSaldanha가 편집 한 질문 – cjds
을 편집하십시오. 지금 더 명확한가요? 나는 프로그래밍 방식으로 하나의 텍스트 뷰를 높이를 바꾸면서 더 큰 것으로 변환하는 아이디어를 얻었습니다. – Beemo
그런 것처럼 textviews를 만드는 대신 열당 하나의 텍스트보기를 만들 수는 없습니다. 새로운 행을 찾으려면 다음 행으로 이동하십시오. 사용자 정의보기로 선을 그릴 수 있습니다. – cjds