大佬教程收集整理的这篇文章主要介绍了android – canvas没有更新,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
public class PlayView extends View { float width,height; float touchatX,touchatY; Boolean isanyBox; public void init() { isanyBox = false; } @Override protected void onSizeChanged(int w,int h,int oldw,int oldh) { // TODO Auto-generated method stub width = w/6f; height = h/6f; super.onSizeChanged(w,h,oldw,oldh); } public PlayView(Context context) { super(context); setFocusable(true); setFocusableInTouchMode(true); init(); } @Override public Boolean onTouchEvent(MotionEvent event) { // TODO Auto-generated method stub isanyBox = true; touchatX = (event.getX()/6)*6; touchatY = (event.getY()/6)*6; return super.onTouchEvent(event); } public void onDraw(Canvas canvas) { Paint lineColor = new Paint(); lineColor.setColor(Color.bLACK); //Box property Paint BoxColor = new Paint(); BoxColor.setColor(Color.bLUE); //Draw horizontal lines for(int i=0; i<6; i++) { canvas.drawLine(0,i*height,getWidth(),lineColor); } //Draw vertical lines for(int j=0; j<6; j++) { canvas.drawLine(j*width,j*width,getHeight(),lineColor); } // if(isanyBox) // { canvas.drawRect(touchatX+1,touchatY+2,touchatX+width-1,touchatY+height-2,BoxColor); // } } }
以上是大佬教程为你收集整理的android – canvas没有更新全部内容,希望文章能够帮你解决android – canvas没有更新所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。