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. tomcat_logs

    tomcat logs 目录下各日志文件的含义 参考地址: http://www.cnblogs.com/signheart/p/0ed0bef7dfadf59534eec76ad4607654.ht ...

  2. 01--Qt扫盲篇

    Qt扫盲篇 1.What is Qt 一个跨平台应用程序和UI开发框架,主要偏向于UI框架方面,由诺基亚公司开发维护. 使用 Qt 只需一次性开发应用程序,无须重新编写源代码,便可跨不同桌面和嵌入式操 ...

  3. C# 取web应用程序运行目录

    HttpRuntime.AppDomainAppPath

  4. location.reload() 和 location.replace()的区别和应用。

    首先介绍两个方法的语法: reload 方法,该方法强迫浏览器刷新当前页面.语法:location.reload([bForceGet])  参数:bForceGet, 可选参数, 默认为 false ...

  5. hibernate增删改查总结

    hibernate操作的都是基于对象的(曾save删delete改update) 进行hql查询是设置参数从零开始(session.setParameter(0,#)) hql查询设置参数可以是其他( ...

  6. linux采用scp命令拷贝文件到本地,拷贝本地文件到远程服务器

    // 假设远程服务器IP地址为 192.168.1.100 1.从服务器复制文件到本地: scp root@192.168.1.100:/data/test.txt /home/myfile/ roo ...

  7. 和大华电子称通讯的奇怪现象-不能关闭Socket客户端的连接

    大华电子称作为socket Server,命令自定义成02+命令+0d0a03格式.,返回给客户端的字符串也是自定义的.这就给懒人造成非常不方便. 最关键的是连接server后,disconnec没有 ...

  8. 6 Javascript:函数

    函数 函数是面向任务的. 当我们面临一个须要可问题的时候.往往无处下手.这时候.须要将问题分解为多个任务,从而逐一击破. 这里就须要函数的帮助. 语法 function Name() { Body() ...

  9. DOMContentLoaded事件<zz>

    今天查看百度空间源代码,发现多了个util.js文件,打开看看.里面里面定义了addDOMLoadEvent.这是干什么用的? 仔细查看代码,发现在Mozilla添加了DOMContentLoaded ...

  10. C# 用ManulResetEvent 控制Thread的 Suspend、Resume

    class Program { static void Main(string[] args) { Thread thread = new Thread(Work); thread.Start(); ...