Jump to content

[résolu] Jauge circulaire


Ice

Recommended Posts

Bonjour, 

 

Je suis en train de développer une application et j'aurais aimé faire quelque chose de ce genre là:

 

post-44999-0-99724700-1374854437.jpg

 

C'est donc une espèce de jauge circulaire que je pourrais remplir en fonction d'un score (0-100).

 

J'ai littéralement cherché toute la journée sans résultat  :(

 

Si quelqu'un sait comment faire, n'hésitez pas.

Edited by Ice
Link to comment
Share on other sites

Hello,

 

Je te conseille de regarder la documentation suivante:

- Bitmap:

https://developer.android.com/reference/android/graphics/Bitmap.html

- Canvas:

https://developer.android.com/reference/android/graphics/Canvas.html

- ArcShape:

https://developer.android.com/reference/android/graphics/drawable/shapes/ArcShape.html#ArcShape(float,%20float)

 

L'idée étant de créer un Bitmap, puis un canvas et enfin dessiner dedans à l'aide de la class ArcShape.

 

Nhdzq

Link to comment
Share on other sites

Ah merci, je me suis un peu écarté de ce que tu m'as dit mais tu m'as mis sur la voie  :D

 
@Override
protected void onDraw(Canvas canvas) {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG );
    //Grey
    paint.setARGB(255,153,153,153);
    canvas.drawCircle(70,70,70,paint);
    //Green
    paint.setARGB(255,0,153,0);
    //                       X Y  W   H
    canvas.drawArc(new RectF(0,0,140,140), 90, scoreToDegree(), true, paint);
    paint.setColor(Color.DKGRAY);
    canvas.drawCircle(70,70,60, paint);
}
Edited by Ice
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...