編輯:關於Android編程
<喎?/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHByZSBjbGFzcz0="brush:java;">public class ErinieShow extends RelativeLayout { Context context; RelativeLayout bg; MyView MyView; int level; public ErinieShow(Context context, int level) { super(context); this.context = context; this.level = level; bg = new RelativeLayout(context); MyView = new MyView(context); bg.addView(MyView); addView(bg); int[] resolution = PhoneUtil.getResolution(context); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( resolution[0], PhoneUtil.getFitHeight(context, 125)); bg.setId(100001); bg.setLayoutParams(params); MyView.setLayoutParams(params); switch (level) { case 0: bg.setBackgroundResource(R.drawable.rewardlevel0); break; case 1: bg.setBackgroundResource(R.drawable.rewardlevel1); break; case 2: bg.setBackgroundResource(R.drawable.rewardlevel2); break; default: bg.setBackgroundResource(R.drawable.rewardlevel3); break; } MyView.init(Color.parseColor("#d3d3d3"), 30, 10); } }
public class MyView extends TextView { private float TOUCH_TOLERANCE; // 填充距離,使線條更自然,柔和,值越小,越柔和。 private Bitmap mBitmap; private Canvas mCanvas; private Paint mPaint; private Path mPath; private float mX, mY; private boolean isDraw = false; int time=0; public MyView(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isDraw) { mCanvas.drawPath(mPath, mPaint); canvas.drawBitmap(mBitmap, 0, 0, null); } } /** * 開啟檫除功能 * * @param bgColor * 覆蓋的背景顏色 * @param paintStrokeWidth * 觸點(橡皮)寬度 * @param touchTolerance * 填充距離,值越小,越柔和。 */ public void init(final int bgColor, final int paintStrokeWidth, float touchTolerance) { TOUCH_TOLERANCE = touchTolerance; // 設置畫筆 mPaint = new Paint(); // mPaint.setAlpha(0); // 畫筆劃過的痕跡就變成透明色了 mPaint.setColor(Color.BLACK); // 此處不能為透明色 mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); // 或者 // mPaint.setAlpha(0); // mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN)); mPaint.setAntiAlias(true); mPaint.setDither(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); // 前圓角 mPaint.setStrokeCap(Paint.Cap.ROUND); // 後圓角 mPaint.setStrokeWidth(paintStrokeWidth); // 筆寬 // 痕跡 mPath = new Path(); // 覆蓋 LayoutParams layoutParams = getLayoutParams(); int height = layoutParams.height; int width; if (getLayoutParams().width == LayoutParams.MATCH_PARENT) { width = 700; } else { width = layoutParams.width; } mBitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); mCanvas = new Canvas(mBitmap); mCanvas.drawColor(bgColor); isDraw = true; } @Override public boolean onTouchEvent(MotionEvent event) { if (!isDraw) { return true; } switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // 觸點按下 // touchDown(event.getRawX(),event.getRawY()); touchDown(event.getX(), event.getY()); invalidate(); break; case MotionEvent.ACTION_MOVE: // 觸點移動 touchMove(event.getX(), event.getY()); invalidate(); break; case MotionEvent.ACTION_UP: // 觸點彈起 touchUp(event.getX(), event.getY()); invalidate(); break; default: break; } return true; } private void touchDown(float x, float y) { mPath.reset(); mPath.moveTo(x, y); mX = x; mY = y; } private void touchMove(float x, float y) { float dx = Math.abs(x - mX); float dy = Math.abs(y - mY); if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) { mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2); mX = x; mY = y; } } private void touchUp(float x, float y) { mPath.lineTo(x, y); mCanvas.drawPath(mPath, mPaint); mPath.reset(); } }
源碼下載http://download.csdn.net/detail/strawberry2013/7682865
1、背景介紹在開發應用過程中經常會遇到顯示一些不同的字體風格的信息猶如默認的LockScreen上面的時間和充電信息。對於類似的情況,可能第一反應就是用不同的多個Text
但是對於我個人來說,我可能更加傾向於用GreenDao,所以今天也為大家帶來了GreenDao的詳細博客,希望大家喜歡,之前也詳細介紹了ORM的思想,如果不
上一篇文章Android 中的 Service 全面總結詳解【下】 介紹了Service的一些知識以及本地Service的使用,如果對Service還不太了解的建議先看下
Android SQLite相關java源碼中多次提到支持 nested transaction。 而SQLite本身不支持嵌套事務,只能使用 savepoint 代替。
Android Gradle Build Error:Some file