网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
public GobangView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setBackgroundColor(0x55ff0000);
initial();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int width = Math.min(widthSize, heightSize);
// 处理View嵌套在ScrollView中的情况:
if (widthMode == MeasureSpec.UNSPECIFIED) {
width = heightSize;
} else if (heightMode == MeasureSpec.UNSPECIFIED) {
width = widthSize;
}
setMeasuredDimension(width, width);
}
/**
- 当View的宽高确定或者发生改变时回调
*/
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
panelWidth = w;
lineHeight = w * 1.0f / LINE_NUMBER;
int pieceWidth = (int) (lineHeight * RATIO_PIECE);
bitmapWhite = Bitmap.createScaledBitmap(bitmapWhite, pieceWidth, pieceWidth, false);
bitmapBlack = Bitmap.createScaledBitmap(bitmapBlack, pieceWidth, pieceWidth, false);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
drawPanel(canvas);
}
private void initial() {
// 初始化画笔
paint.setColor(0x88000000);
paint.setAntiAlias(true);
paint.setDither(true);
paint.setStyle(Paint.Style.STROKE);
// 初始化棋子
bitmapWhite = BitmapFactory.decodeResource(getResources(), R.drawable.piece_white);
bitmapBlack = BitmapFactory.decodeResource(getResources(), R.drawable.piece_black);
}
/**
- 绘制棋盘
*/
private void drawPanel(Canvas canvas) {
for (int i = 0; i < LINE_NUMBER; i++) {
// 横线
int startX = (int) (lineHeight / 2);
int endX = (int) (panelWidth - lineHeight / 2);
int y = (int) ((0.5 + i) * lineHeight);
canvas.drawLine(startX, y, endX, y, paint);
// 竖线
int startY = (int) (lineHeight / 2);
int endY = (int) (panelWidth - lineHeight / 2);
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!**
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新