0

OK, Brief recap, Was asked to create an app for work that records data specific data and display it to the screen when finished. So it would function like so.

press start > press stop > display results.

However, I have just been told by the IT director of my company that he wants to display information in needle graphs (g-force, average speed, top speed) and also wants a flashy way of displaying the others (time taken, distance traveled)

My initial idea is this:

create a needle gauge like thisgauge, but on a smaller scale and have the digit value display below or beside the graph and to just display the distance traveled and time taken displayed as alarm clock style digits. This would all run down the left hand side of the screen in a thin column and then hava a map displaying the starting location and end location with the route taken for the journey

basically I would like it to look like this map (sorry for the crudeness of the drawing) Something along these lines would be perfect!

I think I could work out the map business and the digits for the time and distance readouts but I have never done any really fancy UI stuff.

How would I get started making the needle gauge?

I was thinking of trying a horizontal bar gauge forst maybe? Incase I cant get the needle gauge to work.

Also, I only have a til tuesday! :S

Ian
  • 1,490
  • 6
  • 24
  • 39
  • 1
    Doing a search might help - http://stackoverflow.com/questions/1046256/how-can-i-create-custom-controls-in-android and http://developer.android.com/guide/topics/ui/custom-components.html – arunkumar Aug 05 '11 at 14:25

1 Answers1

1

invision the following very basic idea:

We have our Custom View with a background image which is the gauge without the needle!

So we first implement this using a class that extends View

public class ourGauge extends View {

    private Bitmap bgImage = null;

    public ourGauge(Context context, Bitmap bgImage) {
        super(context);
        this.bgImage = bgImage;
    }

    public ourGauge(Context context) {
        super(context);
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawBitmap(bgImage, 0, 0, null);
    }

}

Now lets add a needle

public class ourGauge extends View {

    private Bitmap bgImage = null;
    private int indicator;
    Paint paint = new Paint(); 

    public ourGauge(Context context, Bitmap bgImage) {
        super(context);
        this.bgImage = bgImage;
    }

    public ourGauge(Context context) {
        super(context);
    }

    public void setIndicator(int indicator){
        this.indicator = indicator;
        invalidate();
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawBitmap(bgImage, 0, 0, null);
        //you could set color based on indicator (speed or sth)
        paint.setColor(Color.BLACK); 
        canvas.drawLine(0, 0, 20, 20, paint);
        //you have to find the formula to get from where to where the line should drawn
    }

}

To make it better

  1. Don't draw the needle using drawLine but rather make it a shape with dimensions
  2. To create dynamic labels for speeds, you should draw them too
  3. etc
Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106
  • 1
    hahahah :P well dont we all !? please keep in mind that this is just a basic idea ! Work on making it a real one – Sherif elKhatib Aug 05 '11 at 14:55
  • Will do, but this will give me a great starting point! After talking with a coworker I think I might make a revision to the idea and go for a semi circle gauge that "fills up" to the desired point. I was going to try accomplish this by having a black background and draw the colours up to the correct point. Imagine as if the gauge I posted above had an "invisible" needle and as it went up it removed the black to reveal the colour. – Ian Aug 05 '11 at 15:26