
5个回答
展开全部
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);
}
}
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);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-28
展开全部
如果只在xml中画好表格的话,那可以参考我的文章,后期加数据,我会给每个textview增加id,然后通过settext方法进行动态更改显示数值! http://blog.csdn.net/vaecer/article/details/9086641
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-28
展开全部
android 没有table 我用的方法是ListView加背影图片
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-28
展开全部
楼主的 表格画好没饿 ·~ 画好了 分享下哈
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-28
展开全部
有可以进行编辑的没有啊,分享下呗,谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |