- 浏览: 5781471 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (890)
- WindowsPhone (0)
- android (88)
- android快速迭代 (17)
- android基础 (34)
- android进阶 (172)
- android高级 (0)
- android拾遗 (85)
- android动画&效果 (68)
- Material Design (13)
- LUA (5)
- j2me (32)
- jQuery (39)
- spring (26)
- hibernate (20)
- struts (26)
- tomcat (9)
- javascript+css+html (62)
- jsp+servlet+javabean (14)
- java (37)
- velocity+FCKeditor (13)
- linux+批处理 (9)
- mysql (19)
- MyEclipse (9)
- ajax (7)
- wap (8)
- j2ee+apache (24)
- 其他 (13)
- phonegap (35)
最新评论
-
Memories_NC:
本地lua脚本终于执行成功了,虽然不是通过redis
java中调用lua脚本语言1 -
ZHOU452840622:
大神://处理返回的接收状态 这个好像没有监听到 遇 ...
android 发送短信的两种方式 -
PXY:
拦截部分地址,怎么写的for(int i=0;i<lis ...
判断是否登录的拦截器SessionFilter -
maotou1988:
Android控件之带清空按钮(功能)的AutoComplet ...
自定义AutoCompleteTextView -
yangmaolinpl:
希望有表例子更好。。。,不过也看明白了。
浅谈onInterceptTouchEvent、onTouchEvent与onTouch
用法在注释中:
import android.animation.Animator; import android.animation.ArgbEvaluator; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.View; /* * ColorAnimationView 实现了滑动 Viewpager 的时候背景色动态变化的过渡效果 * * ColorAnimationView colorAnimationView = (ColorAnimationView) findViewById(R.id.ColorAnimationView); ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setAdapter(adpter); colorAnimationView.setmViewPager(viewPager, resource.length); colorAnimationView.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { Log.e("TAG","onPageScrolled"); } @Override public void onPageSelected(int position) { Log.e("TAG","onPageSelected"); } @Override public void onPageScrollStateChanged(int state) { Log.e("TAG","onPageScrollStateChanged"); } }); <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="cn.taurusxi.guidebackgroundcoloranimation.sample.SampleActivity"> <com.*.ColorAnimationView android:id="@+id/ColorAnimationView" android:layout_width="match_parent" android:layout_height="match_parent"/> <android.support.v4.view.ViewPager android:id="@+id/viewPager" android:padding="30dp" android:layout_width="match_parent" android:layout_height="match_parent"/> </FrameLayout> * @author Administrator * */ public class ColorAnimationView extends View implements ValueAnimator.AnimatorUpdateListener, Animator.AnimatorListener { private static final int RED = 0xffFF8080; private static final int BLUE = 0xff8080FF; private static final int WHITE = 0xffffffff; private static final int GREEN = 0xff80ff80; private static final int DURATION = 3000; ValueAnimator colorAnim = null; private PageChangeListener mPageChangeListener; ViewPager.OnPageChangeListener onPageChangeListener; public void setOnPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { this.onPageChangeListener = onPageChangeListener; } /** * 这是你唯一需要关心的方法 * @param mViewPager 你必须在设置 Viewpager 的 Adapter 这后,才能调用这个方法。 * @param count ,viewpager孩子的数量 * @param colors int... colors ,你需要设置的颜色变化值~~ 如何你传人 空,那么触发默认设置的颜色动画 * */ /** * This is the only method you need care about. * @param mViewPager ,you need set the adpater before you call this. * @param count ,this param set the count of the viewpaper's child * @param colors ,this param set the change color use (int... colors), * so,you could set any length if you want.And by default. * if you set nothing , don't worry i have already creat * a default good change color! * */ public void setmViewPager(ViewPager mViewPager, int count, int... colors) { // this.mViewPager = mViewPager; if (mViewPager.getAdapter() == null) { throw new IllegalStateException( "ViewPager does not have adapter instance."); } mPageChangeListener.setViewPagerChildCount(count); mViewPager.setOnPageChangeListener(mPageChangeListener); if (colors.length == 0) { createDefaultAnimation(); } else { createAnimation(colors); } } public ColorAnimationView(Context context) { this(context, null, 0); } public ColorAnimationView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ColorAnimationView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mPageChangeListener = new PageChangeListener(); } private void seek(long seekTime) { if (colorAnim == null) { createDefaultAnimation(); } colorAnim.setCurrentPlayTime(seekTime); } private void createAnimation(int... colors) { if (colorAnim == null) { colorAnim = ObjectAnimator.ofInt(this, "backgroundColor", colors); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.setDuration(DURATION); colorAnim.addUpdateListener(this); } } private void createDefaultAnimation() { colorAnim = ObjectAnimator.ofInt(this, "backgroundColor", WHITE, RED, BLUE, GREEN, WHITE); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.setDuration(DURATION); colorAnim.addUpdateListener(this); } @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationUpdate(ValueAnimator animation) { invalidate(); // long playtime = colorAnim.getCurrentPlayTime(); } private class PageChangeListener implements ViewPager.OnPageChangeListener { private int viewPagerChildCount; public void setViewPagerChildCount(int viewPagerChildCount) { this.viewPagerChildCount = viewPagerChildCount; } public int getViewPagerChildCount() { return viewPagerChildCount; } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { int count = getViewPagerChildCount() - 1; if (count != 0) { float length = (position + positionOffset) / count; int progress = (int) (length * DURATION); ColorAnimationView.this.seek(progress); } // call the method by default if (onPageChangeListener!=null){ onPageChangeListener.onPageScrolled(position,positionOffset,positionOffsetPixels); } } @Override public void onPageSelected(int position) { if (onPageChangeListener!=null) { onPageChangeListener.onPageSelected(position); } } @Override public void onPageScrollStateChanged(int state) { if (onPageChangeListener!=null) { onPageChangeListener.onPageScrollStateChanged(state); } } } }
发表评论
-
NestedScrollView滚动到顶部固定子View悬停挂靠粘在顶端
2018-10-31 20:45 6819网上有一个StickyScrollView,称之为粘性Scro ... -
自定义Behavior实现AppBarLayout越界弹性效果
2017-03-31 09:33 10252一、继承AppBarLayout.Beha ... -
Android - 一种相似图片搜索算法的实现
2017-03-31 09:33 2573算法 缩小尺寸。 将图片缩小到8x8的尺寸,总共64个 ... -
使用SpringAnimation实现带下拉弹簧动画的 ScrollView
2017-03-30 11:30 2798在刚推出的 Support Library 25.3.0 里面 ... -
Android为应用添加角标(Badge)
2017-03-30 11:21 61121.需求简介 角标是什么意思呢? 看下图即可明了: 可 ... -
Android端与笔记本利用局域网进行FTP通信
2017-03-23 10:17 934先看图 打开前: 打开后: Activity类 ... -
PorterDuffColorFilter 在项目中的基本使用
2017-03-03 10:58 1305有时候标题栏会浮在内容之上,而内容会有颜色的变化,这时候就要求 ... -
迷你轻量级全方向完美滑动处理侧滑控件SlideLayout
2017-01-16 16:53 2553纯手工超级迷你轻量级全方向完美滑动处理侧滑控件(比官方 sup ... -
Effect
2017-01-05 09:57 0https://github.com/JetradarMobi ... -
动态主题库Colorful,容易地改变App的配色方案
2016-12-27 14:49 2529Colorful是一个动态主题库,允许您很容易地改变App的配 ... -
对视图的对角线切割DiagonalView
2016-12-27 14:23 1077提供对视图的对角线切割,具有很好的用户定制 基本用法 ... -
仿淘宝京东拖拽商品详情页上下滚动黏滞效果
2016-12-26 16:53 3425比较常用的效果,有现成的,如此甚好!:) import ... -
让任意view具有滑动效果的SlideUp
2016-12-26 09:26 1668基本的类,只有一个: import android.a ... -
AdvancedWebView
2016-12-21 09:44 16https://github.com/delight-im/A ... -
可设置圆角背景边框的按钮, 通过调节色彩明度自动计算按下(pressed)状态颜色
2016-11-02 22:13 1868可设置圆角背景边框的的按钮, 通过调节色彩明度自动计算按下(p ... -
网络请求库相关
2016-10-09 09:35 62https://github.com/amitshekhari ... -
ASimpleCache一个简单的缓存框架
2015-10-26 22:53 2128ASimpleCache 是一个为android制定的 轻量级 ... -
使用ViewDragHelper实现的DragLayout开门效果
2015-10-23 10:55 3350先看一下图,有个直观的了解,向下拖动handle就“开门了”: ... -
保证图片长宽比的同时拉伸图片ImageView
2015-10-16 15:40 3683按比例放大图片,不拉伸失真 import android. ... -
向上拖动时,可以惯性滑动显示到下一页的控件DragLayout
2015-10-16 14:53 5533仿照淘宝和聚美优品,在商品详情页,向上拖动时,可以加载下一页。 ...
相关推荐
实现滑动ViewPager渐变背景色
guildbackground 实现滑动ViewPager渐变背景色 效果图如下:
竖向滑动viewpager和横向滑动viewpager混用
android垂直滑动viewpager
背景图片自动滚动,根据计算,当ViewPager切换到最后一个页面时,背景也同时滑动到最后,如果背景图片宽度较小,ViewPager每次切换时,背景图片会滑动较小的距离,很多手机的桌面都是实现的相同效果。代码中自定义...
Android利用ViewPager实现类微信的左右滑动效果,详细代码注解解析setOnPageChangeListener各参数意义以及使用方法
这个是一个写的封装的3D效果的左右可以滑动的viewpager,一个非常新的控件的使用,Android4.0以上的版本才支持的。
自定义ViewPager (禁止滑动和去除切换效果) viewPager.setNoScroll(true);//禁止手动滑动
RecyclerViewPager实现类似于竖直滑动的ViewPager,效果
自定义滑动ViewPager 实例 可以当作类库查看 也可以自己研究 自定义View,注释清晰,代码结构简单
可实现ViewPager向前或向后无限循环左右滑动翻页效果
用viewPager实现在页面左右滑动的同时 动态光标 一条用来指示当前页面是viewPager的哪一个页面的横线 实现动态的滑动效果 类似与微信经典界面
本例是用Viewpager在android中实现的页面滑动效果,将代码导入eclipse即可运行。
Android ViewPager实现仿QQ多页面滑动切换以及动画效果
ViewPager实现一个Activity装载多个自定义layout文件,实现左右滑动 页面效果。 (实现电视遥控器效果。)
viewpager+fragment左右滑动实现动态加载数据。动态刷新fragment
viewPager滑动时添加不同角度效果
viewpager的使用非常的方便,不过我在使用的时候遇到一个问题,就是切换view的时候通过获取到pagerchange然后调用animation来实现北京渐变的效果不明显,最后通过调试发现viewpager已经为我们提供了相应的方法,不过...
这个是viewPager模仿android桌面左右滑动的效果!
一款android viewpager 自定义滑动动画效果,很多种效果有你想要的,还可以理解之后自己写出自己想要的效果,很简单,调用就一段代码,不影响性能