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

Background Image Size overrides all size settings #219

Closed AKTanara closed 2 years ago

AKTanara commented 2 years ago

I think in no near future there will be any competitors for this library... Saw huge projects that are using this amazing job as their backbone.

I have three issues and would be thankful if you could take a look into.

  1. When I set background image, image size overrides all size settings and thereafter, the only way to resize the gauge is to resize the image in an external software. Is that how it is meant to be or I'm doing sth wrong? gauge.setBackgroundResource(R.drawable.dial);
<com.github.anastr.speedviewlib.ImageSpeedometer
        android:id="@+id/speedView"
        android:layout_width="50dp"
        android:layout_height="50dp"
        app:sv_centerCircleColor="@android:color/transparent"/>

2021-09-03_233300

  1. As you can see in the image, when I set tick texts and use padding to bring the text more to center and turn rotation off, text is ununiformly spaced from center and needs some padding to shift tick texts up. It is probably because of turned off rotation. By the way it causes a minor aesthetic issue.

  2. Again, as you can see in the image, When choosing different sizes for setSpeedTextSize& setUnitTextSizethere is some alignment issue. Is there any workarounds?

Thanks again for the great job and the effort you put to maintain it.

anastr commented 2 years ago

Hi @AKTanara .

  1. In your example, you're using background resource instead of setImageSpeedometer or app:sv_image attribute.

  2. I think the problem in your indicator image, it has a transparent gap on its both sides. May you try one of the provided indicators (Like app:sv_indicator="NeedleIndicator") to make sure that it's on the correct position? If that so, you need to draw the ticks on the image using an external software to fix your issue.

  3. They are on the same vertical line, it's the braces that causes the issue. Maybe if you change textTypeface could fix the issue.

AKTanara commented 2 years ago

Hi @anastr Thanks for your quick and comprehensive reply and sorry for my late replay.

  1. It actually was the case and setImageSpeedometer solved my issue for good. I don't know how much time and effort are you putting on this project but I think it might be a good idea to add setImageSpeedometer method also to types other than ImageSpeedometer.
  2. Surprising for me and of course not for you the solution for previous problem also solved this one. And I believe there was a positioning problem when I used setBackgroundResource. And fortunately I wont need to put text on my background image and it means a lot cuz now I can set numbers dynamically.
  3. Apparently you are always right. Texts are pretty good aligned but parenthesis isn't. By textTypeface you mean to put the text first in a typeface and then passing it to setUnit instead of a simple string? I would appreciate if you could provide me with a line of example code. Attaching the image just to show how satisfied and pleased I am with the result: 2021-09-08_235010
anastr commented 2 years ago

Hello @AKTanara I'm happy to see people contented with my library. I'll point out some of my answers.

AKTanara commented 2 years ago

Hi Sorry for my late reply. I tried the typeface and different fonts but the parenthesis is always miss aligned. I think I should find some other solution for that. But please let me know if you decided to resolve this minor issue... And again thanks for the whole library and previous replies. Regards 2021-09-17_040023

anastr commented 2 years ago

It's not posable to fix this programmatically, it's about the font and parentheses style. For example if we write here '(A)' you'll notice the same vertical alignment.