Skip to content
Anas Altair edited this page Dec 28, 2019 · 8 revisions

Work With Notes

just for Speedometer family.

Note is a small Popup dialog shown on the speedometer for some time and it will removed automatically, it can be text or image, support Spannable String and multi-lines.

recommend to add padding to Speedometer when you want to use Notes.

Simple Note

it is very easy, by on line, for TextNote :

speedometer.addNote(TextNote(getApplicationContext(), "Stop !!"))

and for ImageNote :

// get bitmap from Resources
val bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)
// create ImageNote, and add it to speedometer
val imageNote = ImageNote(getApplicationContext(), bitmap)
speedometer.addNote(imageNote)

there are some options to TextNote:

val note = TextNote(applicationContext, "Wait !")
        .setPosition(Note.Position.CenterSpeedometer) // position of Note.
        .setAlign(Note.Align.Bottom) // Note Align.
        .setTextTypeFace(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)) // style, or font.
        .setBackgroundColor(Color.parseColor("#EEFF41")) // change dialog color.
        .setCornersRound(20f) // dialog's rectangle Corners Round.
        .setTextSize(speedView.dpTOpx(20f))

add Note for Limited Time

by Default, Note still 3 seconds on speedometer then removed automatically.
if you want to add Note to apply on the Speedometer for limited seconds, you can use speedometer.addNote(note: Note, showTimeMillisecond: long) method, like so:

speedometer.addNote(yourNote, 5000)

add Note for Unlimited Time

use Note.INFINITE to add a Note for unlimited time, but you should be aware that it will be removed, if you call removeAllNotes() method, usage:

speedometer.addNote(yourNote, Note.INFINITE)

Remove All Notes

Easy by simple Line:

speedometer.removeAllNotes()