Question

I'm trying to do animation around View that changes size due to setVisible on it's child. I've got View like that:

<LinearLayout  
xmlns:android="http://schemas.android.com/apk/res/android"  
android:layout_height="wrap_content"  
android:layout_width="fill_parent"  
android:background="@drawable/roundedtable_filled"  
android:layout_margin="8dip"  
android:orientation="vertical">  
    <TextView  
    android:id="@+id/title"  
    style="@style/appInfoTextBold"  
    android:text="Jakie dane powinna uwzględniać reklamacja?" />  
    <TextView  
    android:id="@+id/text"  
    style="@style/appInfoText"  
    android:text="Kochasz kino? Z niecierpliwością czekasz na kolejne odcinki  swoich ulubionych seriali? Marzysz o przeprowadzce do Hollywood? Jeśli tak, to vod.onet.pl jest serwisem właśnie dla Ciebie." />  
</LinearLayout>  

On title clicked I change Visibilisty of text. Now I'd like to have nice animation of growing size of my View. What's the correct way to do that? Maybe I shouldn't change text visibility and instead try resize the view in thread so it would be bigger every 40ms or sth like that?

Was it helpful?

Solution

You should be able to create a ScaleAnimation that scales the view in from some fractional size to its full size. Start the animation at the same time as you set it visible. You might also want to fade it in (AlphaAnimation) so that it doesn't just blink in unless you're scaling up from a fraction of 0 (which would make it invisible because it has no size to begin with). Scaling text never looks that great, but if the animation is quick it might be sufficient.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top