2

I am thinking of showing percentage in some different way in android. Please see the attached image as reference. What I was thinking is that I will add one LinearLayout with weightSum as 100 then inside that i will have one View with 0dp as width and 20dp as height and I will set the View's weight as per the percentage and fill it with some beautiful nice color. This part is very well done and working as well but now I would like to do some animation in it.

Its a horizontal like so I would like to do some animation like from start to end it will go smoothly in horizontal way and stop at whatever percentage I pass. See the image, in that if I took example of Joomla then in that the Blue line start with 0 and quickly proceed to 70% with smooth animation.

Sample Code without Animation :-

<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_below="@id/txtDuration"
        android:weightSum="100" >

        <TextView
            android:id="@+id/lineProgress"
            android:layout_width="0dp"
            android:layout_height="20dp"
            android:layout_marginTop="10dp"
            android:layout_weight="70"
            android:background="@color/tab_stacked_color"
            android:gravity="right"
            android:text="70%"
            android:textColor="@android:color/white" />
    </LinearLayout>

enter image description here Test Code Screen shot

Scorpion
  • 6,831
  • 16
  • 75
  • 123
  • have you looked at using a [ValueAnimator](http://developer.android.com/reference/android/animation/ValueAnimator.html) animating the layout_weight of the TextView and a [DecelerateInterpolator](http://developer.android.com/reference/android/view/animation/DecelerateInterpolator.html)? – panini Apr 24 '14 at 03:58
  • Thanks for your comment but I don't know anything on Animation so don't know how to go ahead but now I will check value animator and other which you suggested and try to achieve what I am trying. Thanks – Scorpion Apr 24 '14 at 04:00
  • 1
    @Scorpion Have u solved this?Will do r n d if u didn't solve. – TheFlash Apr 24 '14 at 11:47
  • Nope, not yet. Still trying.. If you can help in someway then it would be great – Scorpion Apr 24 '14 at 12:20
  • http://android-er.blogspot.in/2013/11/example-of-viewanimator.html I found this link and based on this I am trying to achieve what I want to do. – Scorpion Apr 24 '14 at 12:23
  • @Indiandroid, Hello, any information you got in this? I am not able to do it using the link shared above yet. Please let me know if you got anything useful... – Scorpion Apr 25 '14 at 03:12
  • Hey check this http://stackoverflow.com/questions/10722746/add-dynamic-text-over-android-seekbar-thumb The formula is working you have to put textview and seekbar in Relative layout.I made a demo long time ago but result was not expected but u can try.I will check whenever I m free and let you know. – TheFlash Apr 25 '14 at 04:10

0 Answers0