Animation显示ListView的每一条记录

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".activity.MainActivity">
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/listView"></ListView>
</LinearLayout>

zoom_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <scale android:duration="1000"
        android:fromXScale="0.1"
        android:fromYScale="0.1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="1.0"
        android:toYScale="1.0"/>

    <alpha android:duration="1000"
        android:fromAlpha="0"
        android:toAlpha="1.0"/>

</set>

MainActivity.java

package com.pingyijinren.helloworld.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.pingyijinren.helloworld.R;

public class MainActivity extends AppCompatActivity {
    private ListView listView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        listView=(ListView)findViewById(R.id.listView);
        listView.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,new String[]{"work hard","make money","I want to be rich"}));
//        listView.setAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.zoom_in));
        listView.setLayoutAnimation(new LayoutAnimationController(AnimationUtils.loadAnimation(MainActivity.this,R.anim.zoom_in)));
    }
}

 

posted @ 2016-06-03 11:32  zqxLonely  阅读(198)  评论(0编辑  收藏  举报