我有以下习俗:
我通过使用CanvasdrawArc()
方法实现了这一目的。 然而,如果采用<代码>drawArc()方法,我不能限制弧内rad。
我喜欢的是:
只有一个外环。
我需要的是<条码>drawArc()功能,在这种功能中,我可以确定弧线的内rad。 谁会这样做?
(BTW, overpaating the inner area don t work,因为它需要透明。) 在绘画红色和蓝皮条后,用<条码>Color.TRANSPARENT
我有以下习俗:
我通过使用CanvasdrawArc()
方法实现了这一目的。 然而,如果采用<代码>drawArc()方法,我不能限制弧内rad。
我喜欢的是:
只有一个外环。
我需要的是<条码>drawArc()功能,在这种功能中,我可以确定弧线的内rad。 谁会这样做?
(BTW, overpaating the inner area don t work,因为它需要透明。) 在绘画红色和蓝皮条后,用<条码>Color.TRANSPARENT
你可以使用称为“Clear”的PorterDuff xfermode在内地进行油漆。 这将抹去雕像。
你可以这样做:
Paint paint = new Paint();
final RectF rect = new RectF();
//Example values
rect.set(mWidth/2- mRadius, mHeight/2 - mRadius, mWidth/2 + mRadius, mHeight/2 + mRadius);
paint.setColor(Color.GREEN);
paint.setStrokeWidth(20);
paint.setAntiAlias(true);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStyle(Paint.Style.STROKE);
canvas.drawArc(rect, -90, 360, false, paint);
钥匙载于paint.setStyle(Paint.Style)。 STROKE;
,它把弧中心与你在 setStrokeWidth中定义的中风(例如, draws带一个rad子和20px厚)。
希望!
private static final float CIRCLE_LIMIT = 359.9999f;
/**
* Draws a thick arc between the defined angles, see {@link Canvas#drawArc} for more.
* This method is equivalent to
* <pre><code>
* float rMid = (rInn + rOut) / 2;
* paint.setStyle(Style.STROKE); // there s nothing to fill
* paint.setStrokeWidth(rOut - rInn); // thickness
* canvas.drawArc(new RectF(cx - rMid, cy - rMid, cx + rMid, cy + rMid), startAngle, sweepAngle, false, paint);
* </code></pre>
* but supports different fill and stroke paints.
*
* @param canvas
* @param cx horizontal middle point of the oval
* @param cy vertical middle point of the oval
* @param rInn inner radius of the arc segment
* @param rOut outer radius of the arc segment
* @param startAngle see {@link Canvas#drawArc}
* @param sweepAngle see {@link Canvas#drawArc}, capped at ±360
* @param fill filling paint, can be <code>null</code>
* @param stroke stroke paint, can be <code>null</code>
* @see Canvas#drawArc
*/
public static void drawArcSegment(Canvas canvas, float cx, float cy, float rInn, float rOut, float startAngle,
float sweepAngle, Paint fill, Paint stroke) {
if (sweepAngle > CIRCLE_LIMIT) {
sweepAngle = CIRCLE_LIMIT;
}
if (sweepAngle < -CIRCLE_LIMIT) {
sweepAngle = -CIRCLE_LIMIT;
}
RectF outerRect = new RectF(cx - rOut, cy - rOut, cx + rOut, cy + rOut);
RectF innerRect = new RectF(cx - rInn, cy - rInn, cx + rInn, cy + rInn);
Path segmentPath = new Path();
double start = toRadians(startAngle);
segmentPath.moveTo((float)(cx + rInn * cos(start)), (float)(cy + rInn * sin(start)));
segmentPath.lineTo((float)(cx + rOut * cos(start)), (float)(cy + rOut * sin(start)));
segmentPath.arcTo(outerRect, startAngle, sweepAngle);
double end = toRadians(startAngle + sweepAngle);
segmentPath.lineTo((float)(cx + rInn * cos(end)), (float)(cy + rInn * sin(end)));
segmentPath.arcTo(innerRect, startAngle + sweepAngle, -sweepAngle);
if (fill != null) {
canvas.drawPath(segmentPath, fill);
}
if (stroke != null) {
canvas.drawPath(segmentPath, stroke);
}
}
可通过复制<代码>r 而延伸至圆弧 * E/CN.6/2009/1。 页: 1
也是问题的一部分,但可在一个部分的中间起草一份案文:
textPaint.setTextAlign(Align.CENTER);
Path midway = new Path();
float r = (rIn + rOut) / 2;
RectF segment = new RectF(cx - r, cy - r, cx + r, cy + r);
midway.addArc(segment, startAngle, sweepAngle);
canvas.drawTextOnPath("label", midway, 0, 0, textPaint);
绘画圈和Arc. 下面的法典很少是多余的,但可以帮助。
int sweepAngle sweepAngle = (360/7)%360;
int startAngle = -90;
int x = getWidth()/2;
int y = getHeight()/2;
int radius;
radius = getWidth()/2-50;
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(50);
paint.setColor(Color.WHITE);
paint.setColor(Color.parseColor("#CD5C5C"));
mBarPaintFill.setAntiAlias(true);
canvas.drawCircle(x , y , radius, paint);
paint.setColor(Color.BLUE);
for (int i = 1 ; i<=5 ; i++){
canvas.drawArc(x-radius,y-radius,x+radius,y+radius,startAngle,sweepAngle,false,paint);
startAngle = (startAngle + sweepAngle+20)%360;
}
你可以在沙伯德河后尝试
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="oval" >
<size
android:height="56dp"
android:width="56dp" />
<stroke
android:width="10dp"
android:color="#0000ff" />
</shape>
</item>
<item>
<shape android:shape="oval" >
<size
android:height="24dp"
android:width="25dp" />
<stroke
android:dashGap="10dp"
android:dashWidth="10dp"
android:width="10dp"
android:color="#FF0000" />
</shape>
</item>
I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...
I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...
I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...
I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...
To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?
When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...
I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...
I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...