I figured out what the problem was. As you may not (or not know), the
(x,y) coordinate system on the Android screen is a little different.
The origin is in the top left corner, so therefore x increases across
to the right and y increases down to the bottom.

So instead of:

Java:
RectF clockRect = new RectF(86, 314, 394, 6);


It should have been:

Java:
RectF clockRect = new RectF(86, 6, 394, 314);


It all makes sense now.

On Feb 25, 6:21 pm, xspotlivin <dmbrown2...@gmail.com> wrote:
> I'm trying to create a customized clock that given certain input will
> highlight a certain section of the clock (e.g. draw pie shapes
> highlights on top of the clock).
>
> Here's my problem:
>
> I'm trying to usedrawArcin the Canvas class. I am able to draw 360
> degree arcs, but nothing shows up when I draw any arcs less than 360
> degree. I'd like to draw around 15 degree arcs, but when I put 15 into
> the sweep angle location, nothing gets drawn. It only draws full
> circles (360). Does anyone know what's wrong? Below is my code.
>
> ACTIVITY CLASS:
>
> import android.app.Activity;
> import android.content.pm.ActivityInfo;
> import android.os.Bundle;
> import android.view.Window;
> import android.view.WindowManager;
>
> public class AdherenceClock extends Activity {
>
>         private ClockView clockView = null;
>         public Document xml = null;
>
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>
>         this.clockView = new ClockView(this);
>
>         //Remove the title bar, set to full screen, and set to
> landscrape
>         this.requestWindowFeature(Window.FEATURE_NO_TITLE);
>         this.getWindow().setFlags
> (WindowManager.LayoutParams.FLAG_FULLSCREEN,
>                         WindowManager.LayoutParams.FLAG_FULLSCREEN);
>         setRequestedOrientation
> (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
>
>         setContentView(this.clockView);
>     }
>
> }
>
> CLOCKVIEW CLASS:
>
> package nmm.android.adherenceclock;
>
> import android.content.Context;
> import android.graphics.Canvas;
> import android.graphics.Paint;
> import android.graphics.RectF;
> import android.view.View;
>
> public class ClockView extends View {
>
>         protected final Paint pmColor = new Paint();
>         protected final Paint amColor = new Paint();
>
>         public ClockView(Context context) {
>                 super(context);
>
>   this.setBackgroundDrawable(getResources().getDrawable
> (R.drawable.clockbackground));
>
>                 this.amColor.setARGB(100, 248, 225, 110);
>                 this.pmColor.setARGB(100, 111, 162, 214);
>         }
>
>         @Override
>         protected void onDraw(Canvas canvas) {
>
>                 RectF clockRect = new RectF(86, 314, 394, 6);
>                 canvas.drawArc(clockRect, 0, 20, true, this.amColor);
>         }
>
> }
>
> This doesn't work. It only works for 360 degrees. What's wrong?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to