title: Liquid level animation( Battery Doctor )
body: <p>I want to know how to make this kind of animation in android ( The same in Battery Doctor app ).</p>
  
  <p><img src="https://i.stack.imgur.com/w6J5X.png" alt="Animation from Battery Doctor"></p>
  
  <p>I found a way to do this using two green images with an oppacity of 50% one behind the other and another one on the front to hide the unwanted content ( The circle ),I animate the first green image by XML using the code below</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;rotate
      android:duration="1850"
      android:fromDegrees="-4"
      android:pivotX="50%"
      android:pivotY="50%"
      android:repeatCount="infinite"
      android:repeatMode="reverse"
      android:interpolator="@android:anim/linear_interpolator"
      android:toDegrees="4" /&gt;
  &lt;translate
      android:fromXDelta="0"
      android:toXDelta="0"
      android:fromYDelta="0"
      android:toYDelta="1"
      android:repeatCount="infinite"
      android:repeatMode="reverse"
      android:interpolator="@android:anim/linear_interpolator"
      android:duration="1500" /&gt;
  
  &lt;/set&gt;
  </code></pre>
  
  <p>And the second green one by using this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;rotate
      android:duration="1800"
      android:fromDegrees="-1"
      android:pivotX="50%"
      android:pivotY="50%"
  
      android:repeatCount="infinite"
      android:repeatMode="reverse"
      android:interpolator="@android:anim/linear_interpolator"
      android:toDegrees="1" /&gt;
  &lt;translate
      android:fromXDelta="80"
      android:toXDelta="-4"
      android:fromYDelta="-1"
      android:toYDelta="1"
      android:repeatCount="infinite"
      android:repeatMode="reverse"
      android:interpolator="@android:anim/linear_interpolator"
      android:duration="1500" /&gt;
  
  &lt;/set&gt;
  </code></pre>
  
  <p>But how can I create the view programatically ?I want to set the level dynamically from code. for example myView.setLevel(45);</p>