Android: Zeichnung eines basic-Kreis Umriss zu einem RelativeLayout

Ich hab ein RelativeLayout, ich möchte mit 4 konzentrischen Kreisen (ein radar-Effekt, wenn man so will). Ich möchte in der Lage sich zu verstecken und anzeigen des RelativeLayout, so Frage ich mich, wie genau zu verwenden, Leinwand und Farbe, um einen Kreis zu zeichnen, um das RelativeLayout. Wenn jemand erklären könnte, der Lebenszyklus, wie es funktioniert, das wäre sehr hilfreich. Jetzt habe ich:

setContentView(R.layout.applayout);
myRelLayout = (RelativeLayout) findViewById(R.id.RLRadar);
Canvas canvas = new Canvas();
Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
circlePaint.setColor(0xFF000000);
circlePaint.setStyle(Style.STROKE);
canvas.drawCircle((float) centerX, (float) centerY, (float) (maxRadius / 4), circlePaint);

Bin ich auf dem richtigen Weg? Brauche ich zum konvertieren der Leinwand zu einer Art Bildansicht und hinzufügen, dass die RelativeLayout? Oder ich bin völlig off base hier?

Vielen Dank für jede Hilfe!!!

Edit: Hier der funktionierende code.

//Add the radar to the RadarRL
Picture picture = new Picture();
Canvas canvas = picture.beginRecording(screenWidth, screenHeight);
//Draw on the canvas
Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
circlePaint.setColor(0xFF000000);
circlePaint.setStyle(Style.STROKE);
circlePaint.setStrokeWidth((float) 5.0);
canvas.drawCircle((float) centerX, (float) centerY, (float) (maxRadius / 4), circlePaint);
canvas.drawCircle((float) centerX, (float) centerY, (float) ((3 * maxRadius) / 4), circlePaint);
canvas.drawCircle((float) centerX, (float) centerY, (float) (maxRadius / 2), circlePaint);
canvas.drawCircle((float) centerX, (float) centerY, (float) (maxRadius), circlePaint);      
picture.endRecording();

InformationsquelleAutor Rockmaninoff | 2011-02-22

Schreibe einen Kommentar