赞
踩
@Override public void onDraw(Canvas canvas) { Log.w(TAG, "onDraw(),i="+i); super.onDraw(canvas); for (int l = 0; l < i; l++) { canvas.drawRect(backgRect[l], paint(RED_BOTTOM)); canvas.drawRect(topRect[l], paint(RED_TOP)); canvas.drawRect(lineRect[l], paint(RED_LINE)); Log.w(TAG,"make red"+l); } for (int l = i; l < 9; l++) { canvas.drawRect(backgRect[l], paint(DARK_BOTTOM)); canvas.drawRect(topRect[l], paint(DARK_TOP)); canvas.drawRect(lineRect[l], paint(DARK_LINE)); } } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); for (int i = 0; i < 9; i++) { backgRect[i] = new Rect(getLeft() + (i + 1) * (getRight() - getLeft()) / 10 - 9, 0, getLeft() + (i + 1) * (getRight() - getLeft()) / 10 + 9, getBottom()); lineRect[i] = new Rect(getLeft() + (i + 1) * (getRight() - getLeft()) / 10 - 9, 10, getLeft() + (i + 1) * (getRight() - getLeft()) / 10 + 9, 12); topRect[i] = new Rect(getLeft() + (i + 1) * (getRight() - getLeft()) / 10 - 9, 0, getLeft() + (i + 1) * (getRight() - getLeft()) / 10 + 9, 10); } } public void setLevel(int level) { Log.w(TAG, "level:" + level); if(i!=level){ i = level; invalidate(); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。