anastr / SpeedView

Dynamic Speedometer and Gauge for Android. amazing, powerful, and multi shape :zap:
Apache License 2.0
1.28k stars 321 forks source link

PointerSpeedometer tick labels overlap the speedometer bar and its default tickPadding isn't correct #214

Closed gxcare closed 2 years ago

gxcare commented 3 years ago

Describe the bug Labels of ticks with PointerSpeedometer are drawn below the speed indication. They should be put by default more on the inside to not overlap with the speed indication. It seems also that labels are not set corresponding to tick positions. It would be nice to have the option to let them be drawn on top of the speed indication as well and have the possibility to choose where to put the text.

XML & code <com.github.anastr.speedviewlib.PointerSpeedometer android:id="@+id/speedView" android:layout_width="wrap_content" android:layout_height="wrap_content" app:sv_unit = " Mbps" app:sv_withTremble="false" app:sv_tickNumber="9" app:sv_speedometerColor="#80ff0000"/>

Screenshots immagine

anastr commented 3 years ago

You can play with ticks' position with app:sv_tickPadding="32dp", by default it shouldn't be close to the speedometer's bar. This will be fixed by the next version, you can change sv_tickPadding for now by yourself.

The overlap issue appear only on this type of speedometers. Because it has a responsive speedometer bar that change its color depending on current speed, unlike other speedometers which have a static bar drown only once. So, in this speedometer I think I will have to redraw the ticks over the speedometer bar on each frame. Hope it will not affect the performance though.

Your ticks and marks aren't matching because you have not matching number of ticks and marks. To make them so, you need to set mark number lower than tick number by 2 (Because ticks have min & max positions over marks). In your case you have 8 marks and 10 ticks, so you need either to increase ticks app:sv_tickNumber="10" or decrease marks app:sv_marksNumber="7".

gxcare commented 3 years ago

I was able to fix the position and the ticks following your suggestions. The only problem that remains is then the default settings that should avoid the overlap. It would be nice then to have the possibility to have the marks also at 0% and 100%. To ease initialization in Java setTicks() should take a List as argument, not ArrayList. Thanks.

anastr commented 2 years ago

Fixed in version 1.5.53.