zoukankan      html  css  js  c++  java
  • ListView滚动及RotateAnimation实现图片不停旋转

    一,ListView滚动

    1,滚动条一直显示设置:  

      android:fadeScrollbars="false"
      android:scrollbarFadeDuration="0"

    2,当添加一个Item时,item向上滚动  

      listview_down.smoothScrollToPosition(listview_down.getBottom());
      mAdapter.notifyDataSetChanged();

      此时,每添加一条,都会显示到最底部,从而实现“向上滚动”。

      同理:listview_down.smoothScrollToPosition(0);则滚动到listview第一条item所在的位置。

      

    二,RotateAnimation实现图片不停旋转

      在res/anim文件夹下新建tip.xml文件,内容如下

     1 <?xml version="1.0" encoding="utf-8"?>  
     2 <set xmlns:android="http://schemas.android.com/apk/res/android">  
     3     <rotate  
     4         android:fromDegrees="0"  
     5         android:toDegrees="359"  
     6         android:duration="500"  
     7         android:repeatCount="-1"  
     8         android:pivotX="50%"  
     9         android:pivotY="50%" />  
    10 </set>  

    含义表示从0到359度开始循环旋转,0-359(若设置成360在停止时会出现停顿现象)度旋转所用时间为500ms,旋转中心距离view的左顶点为50%距离,距离view的上边缘为50%距离,即正中心,具体每个含义见下面的具体属性介绍。

    java代码为

    Java代码  收藏代码
    1. Animation operatingAnim = AnimationUtils.loadAnimation(this, R.anim.tip);  
    2. LinearInterpolator lin = new LinearInterpolator();  
    3. operatingAnim.setInterpolator(lin);  

    setInterpolator表示设置旋转速率。LinearInterpolator为匀速效果,Accelerateinterpolator为加速效果、DecelerateInterpolator为减速效果

    参考:http://blog.csdn.net/lamp_zy/article/details/7898107

  • 相关阅读:
    我爱Java系列之---【SpringBoot打成war包部署】
    279. Perfect Squares
    矩阵dfs--走回路
    112. Path Sum
    542. 01 Matrix
    106. Construct Binary Tree from Inorder and Postorder Traversal
    105. Construct Binary Tree from Preorder and Inorder Traversal
    Invert Binary Tree
    563 Binary Tree Tilt
    145 Binary Tree Postorder Traversal
  • 原文地址:https://www.cnblogs.com/Miami/p/4378062.html
Copyright © 2011-2022 走看看