1.效果图

2.需求就是点击item歌曲时,实现一种飞入到预约按钮处的效果

3.思路:在布局文件中加入了一个条目布局,和listView的item一样,点击listView的item时,使用给条目布局执行动画。

code:

xml布局

  <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"> <ListView
android:id="@+id/recycleView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text="this is a songfragment"
android:textSize="21sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/anim_layout"
android:gravity="center_vertical"
android:orientation="horizontal"> <RelativeLayout
android:layout_width="50dp"
android:layout_height="50dp"> <com.multak.cookaraclient.RippleImageView
android:id="@+id/anim_typeImage"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="centerCrop"
android:layout_centerInParent="true" /> <ImageView
android:id="@+id/anim_imageLike"
android:layout_alignParentRight="true"
android:layout_height="15dp"
android:visibility="gone"
android:layout_width="15dp"/>
</RelativeLayout> <ImageView
android:id="@+id/image_SongTitle"
android:layout_width="50dp"
android:layout_height="50dp"
android:clickable="true"
android:src="@mipmap/mp3"
android:visibility="gone" /> <LinearLayout
android:id="@+id/layout"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginLeft="@dimen/imagemagintext"
android:layout_weight="1"
android:orientation="vertical"> <TextView
android:id="@+id/anim_textView_SongName"
android:layout_width="match_parent"
android:layout_height="30dp"
android:paddingTop="5dp"
android:textColor="@color/colorSongName"
android:textSize="@dimen/songnamesize" /> <TextView
android:id="@+id/anim_textView_SongSinger"
android:layout_width="match_parent"
android:layout_height="20dp"
android:textColor="@color/colorSongName"
android:textSize="@dimen/songsingersize" />
</LinearLayout> <RelativeLayout
android:layout_width="50dp"
android:layout_height="50dp"> <com.multak.cookaraclient.RippleImageView
android:id="@+id/image_SongPro"
android:layout_width="30dp"
android:layout_height="30dp"
android:visibility="gone"
android:layout_centerInParent="true"
android:src="@mipmap/favono" />
</RelativeLayout>
</LinearLayout> </RelativeLayout>

code: 给条目布局赋值数据

               /*** 加个预约动画 */
String anim_SongName=ClickSongIndex.getSongName();
String anim_SingerName=ClickSongIndex.getSingerName();
anim_textView_SongName.setText(anim_SongName);
anim_textView_SongSinger.setText(anim_SingerName);
int anim_Type=ClickSongIndex.getFileType();
if(anim_Type==3){
anim_typeImage.setImageResource(R.mipmap.mtv1);
}else if(anim_Type==4){
anim_typeImage.setImageResource(R.mipmap.circle1);
}else if(anim_Type==5){
anim_typeImage.setImageResource(R.mipmap.movie1);
}else{
anim_typeImage.setImageResource(R.mipmap.midi1);
}
if(listFavo.contains(ClickSongIndex.getSongIndex())){
anim_imageLike.setVisibility(View.VISIBLE);
}else{
anim_imageLike.setVisibility(View.GONE);
}
if(MainActivity.DayOrNight==1){
anim_typeImage.ChangeColor(context.getResources().getColor(R.color.lightStyle_TextColor));
}else{
anim_typeImage.ChangeColor(context.getResources().getColor(R.color.darkStyle_TextColor));
}
itemClickOrderAnim(anim_layout,FromX,FromY,Max_X,Max_Y);
/*** 预约动画结束*/

code:执行动画

  private  void itemClickOrderAnim(LinearLayout layout,int fromX,int fromY,int toX,int toY){

        ObjectAnimator animator1 = ObjectAnimator.ofFloat(layout, View.ALPHA, 1, 0);
ObjectAnimator animator2 = ObjectAnimator.ofFloat(layout, "translationY", fromY-240, toY);
ObjectAnimator animator3 = ObjectAnimator.ofFloat(layout, "translationX", fromX, toX);
ObjectAnimator animator4 = ObjectAnimator.ofFloat(layout,"scaleY",1f,0f);
ObjectAnimator animator5 = ObjectAnimator.ofFloat(layout,"scaleX",1f,0f);
AnimatorSet set = new AnimatorSet();
set.playTogether( animator2, animator3,animator4,animator5);
set.setDuration(1200);
set.start();
}

示例:

https://pan.baidu.com/s/1bN2cJ8

  

ListView的Item动画的更多相关文章

  1. android 项目学习随笔十三(ListView实现ITEM点击事件,将已读状态持久化到本地)

    1.因为给LISTVIEW增加了两个头布局,所以在点击事件ITEM索引会增加2,比如原来第一条数据的索引应该为0,增加两个头布局后,它的索引变为        2,为了使LISTVIEW的ITEM在点 ...

  2. android listview中item通过viewpager实现《IT蓝豹》

    android listview中item通过viewpager实现 android listview中item通过viewpager实现,每一个item都支持viewpager实现图片切换功能.本项 ...

  3. android 在 ListView 的 item 中插入 GridView 仿微信朋友圈图片显示。

    转载请声明出处(http://www.cnblogs.com/linguanh/) 先上张效果图: 1,思路简述 这个肯定是要重写 baseAdapter的了,这里我分了两个数据适配器,一个是自定义的 ...

  4. Listview的Item中有CheckBox、Button等的焦点处理

    ListView的item布局中有CheckBox.Button等会获取焦点的控件会抢走焦点,造成ListView的item点击事件相应不了. 解决方法:控件设置 android:clickable= ...

  5. Android 用HorizontalScrollView实现ListView的Item滑动删除 ,滑动错乱 冲突

    用HorizontalScrollView实现类似微信的滑动删除 测试于:Android2.2+ 对于Android来说按键操作已经在减少,越来越多的手势操作层出不穷,今天介绍一款LIstView的I ...

  6. ListView实现Item上下拖动交换位置 并且实现下拉刷新 上拉加载更多

    ListView实现Item上下拖动交换位置  并且实现下拉刷新  上拉加载更多 package com.example.ListViewDragItem; import android.app.Ac ...

  7. 区分listview的item和Button的点击事件

    这两天修改领导通的ListView widget,在ListView中加入Button这类的有 “点击” 事件的widget,发现原来listview的itemclick居然失效了, 后来在网上查资料 ...

  8. ListView的item中有button和checkbox,listview的点击事件无效

    ListView的item中有button和checkbox,listview的点击事件无效,解决办法: 在item布局文件中的根控件中添加属性设置: android:descendantFocusa ...

  9. Android为ListView的Item设置不同的布局

    MainActivity如下: package cc.testlistview; import java.util.ArrayList; import java.util.HashMap; impor ...

随机推荐

  1. Linux系统编程@进程管理(一)

    课程目标: 构建一个基于主机系统的多客户即时通信/聊天室项目 涉及的理论知识 进程控制:僵尸进程/孤儿进程.进程控制.守护进程... 进程间通信:管道.命名管道.信号... 多线程编程: 锁.信号量. ...

  2. C#——面对对象之封装、继承、多态的简单理解

    一.封装 隐藏对象的属性和实现细节,仅对外公开接口,控制在程序中属性的读取和修改的访问级别. 简单来多,就是讲我们所需要的代码打包封装进入一个类里面,便于我们调用,操作.这就是封装. 这样就隔离了具体 ...

  3. 循环语句 for循环、while循环、do while循环

    循环语句可以在满足循环条件的情况下,反复执行某一段代码,这段被重复执行的代码被称为循环体语句,当反复执行这个循环体时,需要在合适的时候把循环判断条件修改为false,从而结束循环,否则循环将一直执行下 ...

  4. linux--ubuntu的下载以及VMware Tool的安装

    1. Ubuntu的下载:http://cn.ubuntu.com/download/ 2. VMware Tool的安装: 第一步:在主机上,从 Workstation Pro 菜单栏中选择虚拟机 ...

  5. 树状数组求LIS

    我真的是咸鱼啊 多少年前的基础了我竟然才弄明白,哭 用树状数组维护<=x的最上上升子序列的最大值即可啊Orz 我真的菜的一笔啊! #include <bits/stdc++.h> u ...

  6. [Papers] Semantic Segmentation Papers(1)

    目录 FCN Abstract Introduction Related Work FCN Adapting classifiers for dense prediction Shift-and-st ...

  7. 00070_Calendar

    1.Calendar类概念 (1)Calendar是日历类,在Date后出现,替换掉了许多Date的方法.该类将所有可能用到的时间信息封装为静态成员变量,方便获取: (2)Calendar为抽象类,由 ...

  8. 【Codeforces Round #493 (Div. 2) B】Cutting

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价 ...

  9. windows FTP自动下载脚本

    新建ftp.dat文件,内容如下 open xxx.xxx.xxx.xxxusernamepasswordcd    lcd x:\filesbinaryhashmget *.*bye 新建run.b ...

  10. 洛谷——P1115 最大子段和

    https://www.luogu.org/problem/show?pid=1115#sub 题目描述 给出一段序列,选出其中连续且非空的一段使得这段和最大. 输入输出格式 输入格式: 输入文件ma ...