導航:首頁 > 操作系統 > 畫表格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相關的資料

熱點內容
foreach計數php 瀏覽:525
php自連接 瀏覽:295
程序員被噴了怎麼辦 瀏覽:707
android消息數 瀏覽:261
為什麼在伺服器里輸不了指令 瀏覽:28
程序員那麼可愛前女友劇情介紹 瀏覽:101
centosjava環境變數配置 瀏覽:552
伺服器主板被鎖如何恢復 瀏覽:129
xpc語言編程軟體 瀏覽:820
光遇安卓怎麼解限制 瀏覽:300
元氣騎士老版源碼 瀏覽:103
助眠解壓音頻小姐姐口腔音 瀏覽:232
sql加密身份證號解碼 瀏覽:162
解壓玩法視頻 瀏覽:466
蘋果xls如何設置加密 瀏覽:208
湖北廣電dns的伺服器地址是多少 瀏覽:529
php獲取原始數據 瀏覽:250
pic單片機如何編程 瀏覽:895
javabyte寫文件 瀏覽:325
java獲取類包名 瀏覽:894