I’m attempting to create an application whose sole purpose is to display a toast notification.
One of the things a toast notification has is a duration. Currently, in Android, the two defaults are LENGTH_SHORT and LENGTH_LONG. However, in my application, I would like to give users the choice of choosing their own duration.
The idea is that when they press the “Custom Length” radio button, the view will expand to reveal another EditText that will allow them to input their own duration. However, I’d like to animate this part (both the entrance and exit).
The problem is, I know nothing about Android animations. I also don’t which method I should use to handle the EditText (should it be created and destroyed each time, or stored somewhere?)
If you’re not sure of what I mean, think of iOS’s WiFi settings page. When you enable WiFi, the networks fade in under it and when you disable it they fade out.
Here’s my RadioGroup XML:
<RadioGroup
android:layout_below="@+id/radioHint"
android:id="@+id/durationGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioShort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:checked="true"
android:text="@string/radioShort" />
<RadioButton
android:id="@+id/radioLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="@string/radioLong" />
<RadioButton
android:id="@+id/radioCustom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="@string/radioCustom" />
</RadioGroup>
Thanks for the help.
You should take a look at these pages: http://developer.android.com/training/animation/index.html
It explains how to make animations like cross-fading between views, zooming views and animating layout changes.