请问如何在一个自定义的控件中 重写onDraw函数来实现:在一个已经draw出来的圆上draw数字
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(Color.rgb(198, 198, 198));
mPaint.setStyle(Style.FILL);@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawCircle(8, 8, 5, mPaint);
// draw num on circle
canvas.drawText("1", 0, 0, mPaint);
}
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(Color.rgb(198, 198, 198));
mPaint.setStyle(Style.FILL);@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawCircle(8, 8, 5, mPaint);
// draw num on circle
canvas.drawText("1", 0, 0, mPaint);
}
解决方案 »
- 请问, android下, 一个应用程序退出时(如skype), android 系统会收到什么消息呢?
- 大家看看logcat打印的信息?
- 怎么让控件总在另一个控件上方位置显示。。
- 关于这样布局的一个思路
- 执行mediaplayer.prepare()方法随机的抛异常?求解答。。。
- 怎样使程序抛出异常后不关掉和卡死
- 关于重写父类方法何时被调用
- 有2000字的文字,想在Android 手机上滑动阅读,应该用什么控件啊?
- org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 文件提前结束
- 老哥们,在安卓6.0以上,我想在代码中改变文件的读写权限,不成功,可能是什么原因呢?
- 如何保存GestureLibrary对象
- 关于GesturePoint(float x, float y, long t)
所以drawText参数y不能为0要不看不到了 paint.setColor(Color.RED);
canvas.drawCircle(8, 8, 5, paint);
paint.setColor(Color.BLUE);
canvas.drawText("1", 0, 12, paint);
canvas.drawCircle(8, 8, 5, paint);
paint.setColor(Color.BLACK);
canvas.drawText("1", 0, 12, paint);