| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.test.hwui; |
| 18 |
|
| 19 |
import android.app.Activity; |
| 20 |
import android.content.Context; |
| 21 |
import android.graphics.Canvas; |
| 22 |
import android.graphics.Paint; |
| 23 |
import android.graphics.Path; |
| 24 |
import android.os.Bundle; |
| 25 |
import android.view.View; |
| 26 |
import android.widget.LinearLayout; |
| 27 |
|
| 28 |
@SuppressWarnings({"UnusedDeclaration"}) |
| 29 |
public class SmallCircleActivity extends Activity { |
| 30 |
@Override |
| 31 |
protected void onCreate(Bundle savedInstanceState) { |
| 32 |
super.onCreate(savedInstanceState); |
| 33 |
|
| 34 |
final LinearLayout layout = new LinearLayout(this); |
| 35 |
layout.setOrientation(LinearLayout.VERTICAL); |
| 36 |
|
| 37 |
View view = new PathView(this); |
| 38 |
layout.addView(view, new LinearLayout.LayoutParams(PathView.SIZE, PathView.SIZE)); |
| 39 |
view = new PathView(this); |
| 40 |
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null); |
| 41 |
layout.addView(view, new LinearLayout.LayoutParams(PathView.SIZE, PathView.SIZE)); |
| 42 |
|
| 43 |
setContentView(layout); |
| 44 |
} |
| 45 |
|
| 46 |
static class PathView extends View { |
| 47 |
private static final int SIZE = 37; |
| 48 |
private final Paint mPaint; |
| 49 |
private final Path mPath; |
| 50 |
|
| 51 |
PathView(Context c) { |
| 52 |
super(c); |
| 53 |
|
| 54 |
mPath = new Path(); |
| 55 |
mPath.addCircle(SIZE * 0.5f, SIZE * 0.5f, SIZE * 0.275f, Path.Direction.CW); |
| 56 |
mPath.addCircle(SIZE * 0.5f, SIZE * 0.5f, SIZE * 0.225f, Path.Direction.CCW); |
| 57 |
|
| 58 |
mPaint = new Paint(); |
| 59 |
mPaint.setAntiAlias(true); |
| 60 |
mPaint.setColor(0xff00ffff); |
| 61 |
} |
| 62 |
|
| 63 |
@Override |
| 64 |
protected void onDraw(Canvas canvas) { |
| 65 |
super.onDraw(canvas); |
| 66 |
|
| 67 |
canvas.drawPath(mPath, mPaint); |
| 68 |
} |
| 69 |
} |
| 70 |
} |