導航:首頁 > 操作系統 > 畫表格android

畫表格android

發布時間:2025-04-10 07:01:12

android 裡面怎麼畫表格呢

public class GameView extends View {

private int firstX = 15; // 起始點x
private int firstY = 15; // 起始點y
private int secondX = 70; // 第二點x
private int secondY = 70; // 第二點y
private int widthNum = 8; // 列
private int heightNum = 9; // 行
private int secondSideX = 60; // 第二列的寬
private int sideY = 50; // 行高
private int firstSidesX = 60; // 第一列的寬

public GameView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
drawForm(canvas);
}

private void drawForm(Canvas canvas) {
Paint paint = new Paint();

paint.setAntiAlias(true);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2);
paint.setStyle(Paint.Style.FILL);

paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.STROKE);
int cellX, cellY, cellBX, cellBY;

for (int i = 0; i < widthNum; i++)

for (int j = 0; j < heightNum; j++) {
if(0 == i) { // 如果是第一列 寬度為firstSidesX
cellX = firstX + i * firstSidesX;
cellY = firstY + j * sideY;
cellBX = firstX + (i + 1) * firstSidesX;
cellBY = firstY + (j + 1) * sideY;
}else{
cellX = secondX + (i - 1) * secondSideX;
cellY = secondY + (j - 1) * sideY;
cellBX = secondX + i * secondSideX;
cellBY = secondY + j * sideY;
}

canvas.drawRect(cellX, cellY, cellBX, cellBY, paint);
int cellsNum = i + j * widthNum;
drawColorText(canvas, cellX, cellY, cellBX, cellBY, cellsNum);
}
}

閱讀全文

與畫表格android相關的資料

熱點內容
gear2刷android 瀏覽:79
怎麼用安卓下載櫻校 瀏覽:580
現在什麼app可以賺錢 瀏覽:155
基礎梁鋼筋圖紙未標注加密區間距 瀏覽:469
通達信指標源碼公式半透明 瀏覽:956
開發什麼手機app好 瀏覽:319
csgo如何在游戲里進入完美伺服器 瀏覽:190
編程教育老師成長心態 瀏覽:257
音頻採集單片機 瀏覽:590
加密管的優點 瀏覽:280
dock基礎命令 瀏覽:345
java編程愛好者 瀏覽:723
做外包程序員怎麼樣 瀏覽:866
程序員技術門檻 瀏覽:473
路由花生殼搭建web伺服器地址 瀏覽:541
小米傳送文件用什麼app 瀏覽:103
哪個領域演算法好 瀏覽:380
用命令行編譯java 瀏覽:677
筆趣閣app哪個是正版手機app 瀏覽:427
程序員這個工作好嗎 瀏覽:898