Charging Animation for Android

Android how to make Battery charging animation

Try TransitionDrawable to accomplish this.

Step 1 - In an xml file in the drawable folder you create something like below:

<?xml version="1.0" encoding="UTF-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Set your different images for each drawable-->
<item android:drawable="@drawable/state_1" />
<item android:drawable="@drawable/state_2" />
<item android:drawable="@drawable/state_3" />
<item android:drawable="@drawable/state_4" />
<item android:drawable="@drawable/state_5" />
</transition>

Step 2 - Then, in your View xml for the actual ImageView, set reference this TransitionDrawable in the android:background attribute.

Step 3 - In your code at appropriate place, initiate the transition as below:

TransitionDrawable transition = (TransitionDrawable) viewObj.getBackground();
transition.startTransition(transitionTime);

Hope this helps.

Animation in status bar in Android

Starter class should implement also stop logic.
Something like:

class Starter implements Runnable {
boolean stopConditionMet = false;
public void run() {
BatteryAnimation.start();
try {
while (!stopConditionMet) { Thread.sleep(500); }
} catch (InterruptedException e) {}
BatteryAnimation.stop();

}
public void stop() { stopConditionMet=true; }

}

(instead of busy wait you can do this with wait()-notifyAll() scheme. The above example if for simplicity).

.. and you'll need to keep the instance of the Starter class inside your Activity. Declaring it anonymously won't allow you to change its value when you need.

Where is the charging animation file on a SGS3 mini

Through my experience with this try the following files:

/system/bin/lpmkey

Or the like.

Liquid level animation( Battery Doctor )

I have finally found a library: WaveView

https://github.com/john990/WaveView

Edit

This library https://github.com/gelitenight/WaveView also does the same thing with more features. You can :

  • Shift the wave horizontally.
  • Set water level.
  • Set vertical size of wave.
  • Set horizontal size of wave.

Custom Android battery icon while phone is charging

If you want an animated icon then you should probably create a widget, you can create one that is similar to an icon but that can be animated when the battery is charging.

For the animation you can use the link posted on the comment of Thomas K.



Related Topics



Leave a reply



Submit