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

熱點內容
總結所學過的簡便演算法 瀏覽:358
南昌哪些地方需要程序員 瀏覽:756
三台伺服器配置IP地址 瀏覽:173
如何用命令方塊連續對話 瀏覽:275
win7linux共享文件夾 瀏覽:304
命令符打開本地服務 瀏覽:599
android應用程序源碼 瀏覽:702
安卓開發工程師簡歷怎麼寫 瀏覽:60
熱水器水量伺服器是什麼意思 瀏覽:117
stk衛星編譯 瀏覽:480
對後台程序員的要求 瀏覽:761
ios大文件夾圖標 瀏覽:626
生的計劃pdf 瀏覽:714
oppoa93加密便簽在哪查找 瀏覽:21
兩個數字的加減乘除運算編程 瀏覽:227
給手機加密碼忘記了怎麼辦 瀏覽:601
單片機運算符 瀏覽:297
移動端微信商城源碼 瀏覽:445
編程貓下一個背景在哪裡 瀏覽:359
javaclasstype 瀏覽:240