码迷,mamicode.com
首页 > 其他好文 > 详细

Listview加载动画

时间:2017-09-06 09:53:49      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:from   加载   pre   activity   span   ada   select   undle   fill   

private ArrayList<String> list;
    private Handler handler=new Handler();
    private ArrayAdapter<String> adapter;
    private GridView grid;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView tv= (TextView) findViewById(R.id.tv);
         grid= (GridView) findViewById(R.id.brid);
        Animation animation=new ScaleAnimation(1.0f,2.0f,1.0f,2.0f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
        animation.setDuration(5000);
        animation.setFillAfter(true);
        tv.startAnimation(animation);
         list=new ArrayList<String>();
        for (int i=0;i<10;i++){
           list.add("我是第"+i+"");
        }

         adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,list);
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                grid.setAdapter(adapter);
            }
        },5000);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.bwie.wangshaoliang20170906.MainActivity">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tv"
        android:text="哈哈哈哈哈"
        android:layout_gravity="center"
        />
<GridView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/brid"
    android:layout_marginTop="1dp"
    android:listSelector="@color/colorAccent"
    android:drawSelectorOnTop="false"
    android:fadingEdgeLength="0.0dp"
    android:layoutAnimation="@anim/grid_layout"
    android:cacheColorHint="@android:color/transparent"
    >


</GridView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%"
    android:fromYDelta="0"
    android:toXDelta="0"
    android:toYDelta="0"
    android:duration="2550"
    android:interpolator="@android:anim/anticipate_overshoot_interpolator"></translate>
</set>
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
    android:animation="@anim/liat_anim"
    android:animationOrder="normal"
    android:delay="0.5" />

 

Listview加载动画

标签:from   加载   pre   activity   span   ada   select   undle   fill   

原文地址:http://www.cnblogs.com/yu12/p/7482850.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!