I am writing the application Aqua Balance . Helps control the amount of water you drink. It is necessary to animate the filling of the bottle when you press the button to drink, draw the amount of water you have drunk as a percentage of the size of the bottle. Now I have 10 pictures there, and they change each other. It suited me until I added the settings to the application (at the moment you can only drink 2 liters, with no choice). After adding the setting, the volume changes, and it is not correct to use old pictures.

Question: tell me in what way it is better to implement it, where to dig, what to read?

I did this, found the size of the bottle ( view.getHeight(); view.getWidth(); ), and drew a rectangle as a percentage. But this is not entirely successful, because The size was only after the click, and when it is first opened it does not draw, and it is also necessary to delete and draw again each time, both the bottle and the water, which leads to rubbing up the tips on the buttons.

Thank you in advance.

  • and there was no animation at all? just replacing it turns out the layers painted in water color? By the way, in the appendix, the shadow remains when filling the water on the screen shows that it is not very beautiful. - Shwarz Andrei
  • Animation has never been before - Dmitry Alexandrov

1 answer 1

Well, like you can add svg to android. Draw the original bottle, and the filling is already done in height. for example, the height of a bottle is 500. Capacity is 100 ml. The ratio is 5: 1. Here also draw 1/5 from a bottle if drank 20 ml.

  • This is a direct example of when, do not use vector graphics for such a simple animation. There is a huge number of ways to do this beautifully, and not to load the flow. You absolutely wrong answer. - Shwarz Andrei
  • Can you tell me a couple of them?) - Dmitry Alexandrov
  • @ShwarzAndrei, I'm not saying that he is correct. I just express my opinion. IMHO, so to speak. - DenShDen