To achieve the effect first:
Add text content to the ListView and add animation effects to the text content added to the ListView
Step One:
First define the good one animation file, write the animation effect to be implemented.
1. Create the Anim folder under the Res folder
2. Add a fd.xml (file name customization) file in the Anim folder
Fd.xml content:
<!--Combo Animation duration: The interval between the time--><set android:duration= " xmlns:android="/http/ Schemas.android.com/apk/res/android "> <!--x, Y axis Changes-- <translate android:fromxdelta=" 100% " android:fromydelta=" 100% " android:toxdelta=" 0 " android:toydelta=" 0 " /> <!-- Transparency changes-- <alpha android:fromalpha= "0" android:toalpha= "1" /></set>
Step Two:
Add a ListView to the main layout file Activity_main.xml
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "Match_ Parent " android:layout_height=" match_parent " android:orientation=" vertical " > <listview android:id= "@+id/mylist" android:layout_width= "match_parent" android:layout_height= "Wrap_content" ></ListView></LinearLayout>
Step three: Implementation of Java code
Package Com.contentprovide.liuliu.myapplication;import Android.os.bundle;import Android.support.v7.app.appcompatactivity;import Android.view.animation.animation;import Android.view.animation.animationutils;import Android.view.animation.layoutanimationcontroller;import Android.widget.arrayadapter;import Android.widget.listview;import Java.util.arraylist;public class MainActivity Extends Appcompatactivity {Layoutanimationcontroller layoutanimationcontroller;//animation controller ListView mylist; Defines the adapter used to map the contents into the ListView arrayadapter<string> Arrayadapter; The definition collection is used to add content and add content to the adapter arraylist<string> ArrayList; @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); MyList = (ListView) Findviewbyid (r.id.mylist);////animation file to animation variable Animation Animation = Animationutils.loadanima tion (Getapplicationcontext (), R.ANIM.FD);//Instantiate the animation controller variable and pass the animation variable into the controller Layoutanimationcontroller = new Layoutanimationcontroller (animation);//Set related properties by Controller Layoutanimationcont Roller.setdelay (1.0f);//Animation interval time Layoutanimationcontroller.setorder (layoutanimationcontroller.order_normal);// Sort by//bind the animation and the ListView to each other mylist.setlayoutanimation (Layoutanimationcontroller);//Instantiate the collection and pass the data into the collection ArrayList = new arraylist<> (); for (int a = 0; a < a++) {Arraylist.add ("11"); }//Add the contents of the collection to the adapter Arrayadapter = new Arrayadapter<> (Mainactivity.this, R.layout.support_simple_spinn Er_dropdown_item, arrayList);//Add the adapter to the ListView Mylist.setadapter (Arrayadapter); }}
Add animations to layout files under layouts in Android