zoukankan      html  css  js  c++  java
  • android 给listview或gridview添加数据加载时的动画

    该listview实现图片的异步加载,并在加载listview数据时,添加从左向右的动画效果。

    在res目录下添加anim文件夹,创建动画xml   list_anim.xml

    <?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="500"
            android:interpolator="@android:anim/anticipate_overshoot_interpolator"/>
    
    </set>

    然后,在anim目录下再创建一个xml  navagation_gridview_anim.xml,这个xml代码不多,就四行

    <layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
        android:animation="@anim/list_anim"
        android:animationOrder="normal"
        android:delay="0.5"/>

    现在,给listview或者gridview添加layoutAnimation属性

    <ListView 
            android:id="@+id/listview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#00000000"
            android:cacheColorHint="#00000000"
            android:layoutAnimation="@anim/navagation_gridview_anim"></ListView>

    至此,listview就实现了数据加载时添加动画效果

  • 相关阅读:
    Node 修改默认镜像源
    Mac下apache虚拟主机配置
    Grep命令出现 Binary file (standard input) matches
    idea取出方法参数提示
    Java8 Optional用法
    Codeforces Round #638 (Div. 2)
    Codeforces Round #637 (Div. 2)
    Codeforces Round #636 (Div. 3)
    Tree
    Educational Codeforces Round 85
  • 原文地址:https://www.cnblogs.com/dcxz/p/3824000.html
Copyright © 2011-2022 走看看