- 浏览: 61669 次
- 性别:
- 来自: 湖南
最新评论
-
Neacy_Zz:
有些Android也可以显示的出来。
Android 将一张CMYK模式的图片转换成RGB模式的图片 -
hold_on:
AsyncTask 2.3 和 4.0稍有不同
Android从零开始(十五)
一个乐动力的刷新动画
源码下载戳这里:
package com.example.ledonglidemo; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.util.AttributeSet; import android.view.ViewGroup; import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.LinearInterpolator; import android.view.animation.RotateAnimation; import android.view.animation.ScaleAnimation; import android.widget.ImageView; public class GuideView extends ViewGroup { /** * 左边的图片 */ private ImageView left; /** * 右边的图片 */ private ImageView right; /** * 上面的图片 */ private ImageView top; /** * 下面的图片 */ private ImageView bottom; /** * 中间的图片 m */ private ImageView center; /** * 屏幕的宽度 */ private int screenW; /** * 屏幕的高度 */ private int screenH; public GuideView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context); } public GuideView(Context context, AttributeSet attrs) { super(context, attrs); init(context); } public GuideView(Context context) { super(context); init(context); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // TODO Auto-generated method stub super.onMeasure(widthMeasureSpec, heightMeasureSpec); } private List<Bitmap> bitmaps = new ArrayList<Bitmap>(); private void init(Context context) { left = new ImageView(context); left.setImageBitmap(BitmapFactory.decodeResource( context.getResources(), R.drawable.day)); bitmaps.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.day)); right = new ImageView(context); right.setImageBitmap(BitmapFactory.decodeResource( context.getResources(), R.drawable.night)); bitmaps.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.night)); top = new ImageView(context); top.setImageBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.up)); bitmaps.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.up)); bottom = new ImageView(context); bottom.setImageBitmap(BitmapFactory.decodeResource( context.getResources(), R.drawable.down)); bitmaps.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.down)); center = new ImageView(context); center.setImageBitmap(BitmapFactory.decodeResource( context.getResources(), R.drawable.animation_battery)); bitmaps.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.animation_battery)); screenW = ((Activity) context).getWindowManager().getDefaultDisplay() .getWidth(); screenH = ((Activity) context).getWindowManager().getDefaultDisplay() .getHeight(); this.addView(center); this.addView(left); this.addView(right); this.addView(top); this.addView(bottom); } private LinearInterpolator interpolator = new LinearInterpolator(); @Override protected void onLayout(boolean arg0, int arg1, int arg2, int arg3, int arg4) { // TODO Auto-generated method stub // 五个控件的布局 center.layout(screenW / 2 - bitmaps.get(4).getWidth() / 2, screenH / 2 - bitmaps.get(4).getHeight() / 2, screenW / 2 + bitmaps.get(4).getWidth() / 2, screenH / 2 + bitmaps.get(4).getHeight() / 2); top.layout(screenW / 2 - bitmaps.get(2).getWidth() / 2, screenH / 2 - bitmaps.get(4).getHeight() / 2 - bitmaps.get(2).getHeight() + bitmaps.get(2).getWidth() / 2 / 4, screenW / 2 + bitmaps.get(2).getWidth() / 2, screenH / 2 - bitmaps.get(4).getHeight() / 2 + bitmaps.get(2).getWidth() / 2 / 4); left.layout(screenW / 2 - bitmaps.get(0).getWidth() * 2 - bitmaps.get(0).getWidth() / 4, screenH / 2 - bitmaps.get(0).getHeight() / 2, screenW / 2 - bitmaps.get(0).getWidth() - bitmaps.get(0).getWidth() / 4, screenH / 2 + bitmaps.get(0).getHeight() / 2); right.layout(screenW / 2 + bitmaps.get(1).getWidth() + bitmaps.get(1).getHeight() / 4, screenH / 2 - bitmaps.get(1).getHeight() / 2, screenW / 2 + bitmaps.get(1).getWidth() * 2 + bitmaps.get(1).getHeight() / 4, screenH / 2 + bitmaps.get(1).getHeight() / 2); bottom.layout(screenW / 2 - bitmaps.get(3).getWidth() / 2, screenH / 2 + bitmaps.get(4).getHeight() / 2 - bitmaps.get(3).getWidth() / 2 / 4, screenW / 2 + bitmaps.get(3).getWidth() / 2, screenH / 2 + bitmaps.get(4).getHeight() / 2 + bitmaps.get(3).getHeight() - bitmaps.get(3).getWidth() / 2 / 4); playCenter(); playTop(); playBottom(); playLeft(); playRight(); } /** * 右边的动画 */ private void playRight() { // 混合动画 AnimationSet animationSet = new AnimationSet(false); RotateAnimation rotateRight = new RotateAnimation(0, 359, Animation.ABSOLUTE, screenW / 2 - right.getLeft(), Animation.ABSOLUTE, (right.getBottom() - right.getTop()) / 2); RotateAnimation rotateSelf = new RotateAnimation(0, -359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // 播放时间 rotateSelf.setDuration(10 * 1000); // 播放加速的模式 rotateSelf.setInterpolator(interpolator); // 设置无限循环 rotateSelf.setRepeatCount(-1); rotateRight.setDuration(10 * 1000); rotateRight.setRepeatCount(-1); rotateRight.setInterpolator(interpolator); animationSet.addAnimation(rotateSelf); animationSet.addAnimation(rotateRight); // 播放混合动画 right.startAnimation(animationSet); } /** * 左边的动画 */ private void playLeft() { AnimationSet animationSet = new AnimationSet(false); RotateAnimation rotateLeft = new RotateAnimation(0, 359, Animation.ABSOLUTE, screenW / 2 - left.getLeft(), Animation.ABSOLUTE, (left.getBottom() - left.getTop()) / 2); rotateLeft.setDuration(10 * 1000); rotateLeft.setInterpolator(interpolator); rotateLeft.setRepeatCount(-1); RotateAnimation rotateSelf = new RotateAnimation(0, -359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateSelf.setDuration(10 * 1000); rotateSelf.setRepeatCount(-1); rotateSelf.setInterpolator(interpolator); animationSet.addAnimation(rotateSelf); animationSet.addAnimation(rotateLeft); left.startAnimation(animationSet); } /** * 下面的动画 */ private void playBottom() { RotateAnimation rotateBottom = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.ABSOLUTE, screenH / 2 - bottom.getTop()); rotateBottom.setDuration(10 * 1000); rotateBottom.setInterpolator(interpolator); rotateBottom.setRepeatCount(-1); bottom.startAnimation(rotateBottom); } /** * 上面的动画 */ private void playTop() { RotateAnimation rotateAnimation = new RotateAnimation(0, 359, Animation.ABSOLUTE, screenW / 2 - top.getLeft(), Animation.ABSOLUTE, screenH / 2 - top.getTop()); rotateAnimation.setDuration(10 * 1000); rotateAnimation.setInterpolator(interpolator); rotateAnimation.setRepeatCount(-1); top.startAnimation(rotateAnimation); } /** * 中间的View动画播放 */ private void playCenter() { AnimationSet animationSet = new AnimationSet(false); ScaleAnimation scaleSmall = new ScaleAnimation(1.0f, 0.6f, 1.0f, 0.6f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); ScaleAnimation scaleBig = new ScaleAnimation(1.0f, 5.0f / 3, 1.0f, 5.0f / 3, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleBig.setDuration(2 * 1000); scaleBig.setInterpolator(interpolator); scaleSmall.setDuration(2 * 1000); scaleSmall.setStartOffset(2 * 1000); scaleSmall.setRepeatCount(-1); scaleSmall.setFillEnabled(true); scaleSmall.setFillAfter(true); scaleBig.setStartOffset(2 * 1000); scaleBig.setRepeatCount(-1); scaleBig.setFillEnabled(true); scaleBig.setFillAfter(true); scaleSmall.setInterpolator(interpolator); animationSet.addAnimation(scaleBig); animationSet.addAnimation(scaleSmall); center.startAnimation(animationSet); } }
源码下载戳这里:
- GuideView.zip (42.3 KB)
- 下载次数: 4
发表评论
-
Android自定义控件--2(数字签名)
2014-02-26 11:08 918客户信息交互用到的一个数字签名,保存的是bmp图片(我那会在P ... -
Android自定义控件--1(TextView跑马灯效果)
2014-02-26 10:57 1554N久没有跟新了,最近 ... -
Android 将一张CMYK模式的图片转换成RGB模式的图片
2013-06-25 17:32 2213Android系统是不能够显示打印模式(CMYK)的图片的。所 ... -
Android TextToSpeech语音播放文本
2013-06-25 17:17 1850步骤一、初始化 package com.example.spe ... -
Android连接电脑eclipse无法识别=解决办法
2013-05-23 09:25 21391、方法一:“我的电脑”-->“属性”-->“设备 ... -
Android BaseAdapter如何获得每一项并添加按钮事件
2013-05-21 15:11 3733package com.hangcheng; impor ... -
Android的VideoView如何循环播放
2013-05-15 14:01 4831package com.hangcheng; impor ... -
Android如何获取asset目录下所有文件的路径
2013-05-15 09:48 7690package com.hangcheng.util; ... -
Android--WebView+HTML+Javascript
2013-04-09 17:17 1708知识点:android的WebView控件加载HTML并通过j ... -
VideoView重绘
2013-04-01 23:39 1327知识点:Android中的VideoView控件默认情况下是不 ... -
Android从零开始—多媒体(二十二)
2013-03-06 21:43 1030知识点:音乐播放、录音、播放视频、录像、拍照 步骤一、主界面 ... -
Android从零开始—监听广播BroadcastReceiver(二十一)
2013-03-05 10:17 2081知识点:电话拒接+短息 ... -
Android从零开始—电话+短信(二十)
2013-03-05 10:03 1137知识点:系统电话号码和短信的获取(最好用真机,模拟器上木有电话 ... -
Android从零开始(十九)
2013-02-27 10:35 960知识点:back键的处理(有时候我们可能会不小心按了回退键,但 ... -
Android从零开始(十八)
2013-02-27 10:24 837知识点:菜单(menu) 步骤一、创建菜单项(核心代码如下) ... -
Android从零开始(十七)
2013-02-27 10:09 941知识点:抽屉(SlidingDrawer) 先看一下抽屉打开 ... -
Android从零开始(十六)
2013-02-26 19:43 840知识点:闪屏(通常在 ... -
Android从零开始(十五)
2013-02-26 18:32 1085知识点:异步任务AsyncTa ... -
Android从零开始(十四)
2013-02-26 17:16 833知识点:TabHost选项卡之 ... -
Android从零开始(十三)
2013-02-23 22:57 813知识点:TabHost 效果图: 工程目录结构: ...
相关推荐
custom工程演示了App开发的自定义控件相关知识,包括:自定义视图的步骤(声明属性、构造对象、测量尺寸、绘制视图)、自定义简单动画(任务片段、下拉刷新动画、圆弧进度动画)、自定义对话框的操作(对话框、改进...
【DECREEPTED】 TwinklingRefreshLayout 中文文档 TwinklingRefreshLayout extended the thoughts of SwipeRefreshLayout,using a ViewGroup to include a list of Views, to maintain its low coupling and high ...
|--自定义控件风格和全局背景 |--自定义组合控件 |--自定义配置文件资源 |--自定义颜色状态选择资源 |--自定义颜色资源 |--获取网页的源码 |--读取外部资源的文件3种方式 |--读取手机内的短信 |--通信之Application...
看起来很炫酷,其实实现原理相当简单,我们只需要写自定义控件继承TextView,然后使用渲染器Gradient设置颜色渐变和Paint的setShadowLayer方法设置阴影,然后不断刷新改变位移即可。 实现 首先写一个...
该下拉刷新控件采用流畅的动画效果,提供轻松的用户体验。当用户下拉刷新时,控件将显示一个自定义的刷新头部,并在数据加载完成后自动隐藏。此外,它还支持设置刷新触发距离、刷新超时时间和刷新成功或失败的提示。...
扩展自定义属性,添加下拉头部控件中文字自定义。 2016-12-02 FunGameRefreshView 支持 GridView, ListView, RecycleView 等一些控件 FunGameRefreshView 中只能放入一个子控件 修复游戏结束提示语未设置时,报错...
AnotateView 绘制自定义控件 模仿一点资讯最新客户端下拉刷新动画 > > >
CustomListView是一个功能强大的Android开源库,它为标准的ListView控件带来了下拉刷新等自定义增强功能。通过集成这个资源包,开发者能够在自己的应用程序中轻松实现滑动下拉以刷新列表的功能,极大地提升了用户...
包含模块 仿微信聊天,仿微信图片上传, 九宫格解锁,下拉刷新组件, 流式布局组件,轮播图片、广告, ... 树形控件,QQ5.0侧滑菜单,自定义title, ViewPager切换动画,仿微信主界面,星型菜单
看到ios版上QQ刷新效果像水滴,然后自己也想着去实现这样的效果,这篇文章暂时没有介绍下拉刷新的效果,只是单独用一个控件来实现这样的水滴效果。 效果图如下: 一、总体思路 1、画两个圆形,其中一个就是上面的大...
//修改代码实现 自己的下载刷新动画 LoadingLayout createLoadingLayout(Context context, Mode mode, Orientation scrollDirection, TypedArray attrs) { switch (this) { case ROTATE: default: //帧动画 ...
android-PullAnimation 这是一个在项目中用来处理列表下拉刷新对动画 这个demo包含了大多数自定义控件需要用到技巧,只是针对对View对自定义而言,但是不包括与用户对交互,只是作为学习用途,和大家分享
scrollbarviewdemo :fire:1. CoordinatorLayout+AppBarLayout+CollapsingToolbarLayout+Toolbar(android新控件使用,实现根据头布局,bar根据滑动显示隐藏...3.自定义上拉刷新,加载更多框架,可支持定制化刷新动画...
怎样通过制作自定义控件实现页面的 滑动返回 效果 怎样实现隐藏 ToolBar 以及其他的优美 动效 怎样通过 DrawerLayout 实现侧滑菜单的效果 怎样进行网络内容的异步加载以及数据缓存 怎样使用 Gradle 轻松完成项目...
一个强大并且灵活的 Android RecyclerViewAdapter。 优化Adapter代码(减少百分之70%代码) 添加点击item点击、长按事件、以及item子控件的点击事件 添加加载动画(一行代码轻松切换5种默认动画) 添加头部、尾部...
Android 毕业设计仿斗鱼 Flutter 设计(内附源码,下载即可) 博客地址:https://blog.csdn.net/JasonXu94?type=blog 实现的功能 1. flutter重构的斗鱼直播APP 2. 首页、娱乐为Material组件;直播间、鱼吧为纯自定义...
自定义控件,如对话框背景等,或去google code找些开源的代码下来研究,学习人家的设计思想、模块功能的划分、代码组织结构等知识 这个过程中,涉及到的知识比较多,如版本管理工具SVN、Git、Mercurial,如设计模式...
ANDROID 界面刷新 174 MESSAGE HANDER 175 用法: 175 线程与子线程调用MessageHander 177 Messagehandler实例 177 8、数据存储与读取 179 1. PREFERENCES 179 2. FILES 180 3. DATABASES 180 4. NETWORK 183 5、...
作者aliouswang,源码FriendRefreshView,微信朋友圈我们都经常用,朋友圈的下拉刷新比较有意思,我们今天将要模仿打造微信朋友圈的下拉刷新控件,当然微信的这种刷新设计可能不是最好的,实际项目中你可以用V4包...