仿京东顶部加载动画
2015-11-21 14:35
169 查看
昨天的时候我们仿照了一个美团的加载的图标的小人,今天我们也来看看京东在下拉刷新的时候也会有一个快递的小人是怎么实现的,还是依靠惯例,我们解压一下它的apk,然后去里面找一找那些素材,发现原来也有几张图片,原来它的原理是和美团是一样的,其他的就不多说了。
我们先把素材取出来再说:
接下来我们就在drawable 目录下新建一个 loading_jd.xml 文件
然后我们在我们的布局文件中的使用:
3、接下来我们就在Activity中开启帧动画
其实这个动画是非常简单的,就是利用了Android里面的帧动画来实现的,通过多张图片的无限循环的播放来达到这个效果,最后我们看看这个效果与我们的效果是不是一样的。
我们先把素材取出来再说:
接下来我们就在drawable 目录下新建一个 loading_jd.xml 文件
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" > <item android:drawable="@drawable/app_refresh_people_0" android:duration="60"></item> <item android:drawable="@drawable/app_refresh_people_1" android:duration="60"></item> <item android:drawable="@drawable/app_refresh_people_2" android:duration="60"></item> <item android:drawable="@drawable/app_refresh_people_3" android:duration="60"></item> </animation-list>
然后我们在我们的布局文件中的使用:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" > <ImageView android:id="@+id/iv_loading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/loading_jd" android:layout_gravity="center" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="10dip" android:textSize="18sp" android:text="加载中。。。" /> </LinearLayout>
3、接下来我们就在Activity中开启帧动画
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_main); ImageView iv_loading = (ImageView) findViewById(R.id.iv_loading); AnimationDrawable loadingDrawable = (AnimationDrawable) iv_loading.getDrawable(); loadingDrawable.start(); } }
其实这个动画是非常简单的,就是利用了Android里面的帧动画来实现的,通过多张图片的无限循环的播放来达到这个效果,最后我们看看这个效果与我们的效果是不是一样的。
相关文章推荐
- jQuery sibings()的作用
- linux 更换 软件源后 GPG错误
- 算法虐我千百遍,我待算法如初恋
- Git基本操作
- ORACLE Instant Client 安装
- java 文件传输 分块传输
- JS:offsetWidth\offsetleft 等图文解释
- 实习小白::(转) Cocos2d-x 3.0 开发(八)骨骼动画的动态换肤
- PAT 1041. Be Unique (20)
- C++ 学习(继承和动态内存分配)
- 图像处理opencv直方图均值化-学习笔记2
- C#基础篇总结(二)
- Http常见返回数据
- 深入解析C++ STL中的常用容器
- 11g 新特性 CHM(Cluster Health Monitor)
- 重学C语言(一) 字符串数组输出
- 实习小白::(转) Cocos2d-x 3.0 开发(四)使用CocoStudio创建UI并载入到程序中
- HDU 1864最大报销额 01背包问题
- dubbo hello word
- delphi事务处理