- 浏览: 5770112 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (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.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; import static java.lang.Math.abs; import static java.lang.Math.floor; /** * Created by thijs on 08-06-15. */ public class ScrollingImageView extends View { private final int speed; private final Bitmap bitmap; private Rect clipBounds = new Rect(); private int offset = 0; private boolean isStarted; public ScrollingImageView(Context context, AttributeSet attrs) { super(context, attrs); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ParallaxView, 0, 0); try { speed = ta.getDimensionPixelSize(R.styleable.ParallaxView_speed, 10); bitmap = BitmapFactory.decodeResource(getResources(), ta.getResourceId(R.styleable.ParallaxView_src, 0)); } finally { ta.recycle(); } start(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), bitmap.getHeight()); } @Override public void onDraw(Canvas canvas) { super.onDraw(canvas); if (canvas == null) { return; } canvas.getClipBounds(clipBounds); int normalizedOffset = offset; int layerWidth = bitmap.getWidth(); if (offset < -layerWidth) { offset += (int) (floor(abs(normalizedOffset) / (float) layerWidth) * layerWidth); } int left = offset; while (left < clipBounds.width()) { canvas.drawBitmap(bitmap, getBitmapLeft(layerWidth, left), 0, null); left += layerWidth; } if (isStarted) { offset -= speed; postInvalidateOnAnimation(); } } private float getBitmapLeft(int layerWidth, int left) { float bitmapLeft = left; if (speed < 0) { bitmapLeft = clipBounds.width() - layerWidth - left; } return bitmapLeft; } /** * Start the animation */ public void start() { if (!isStarted) { isStarted = true; postInvalidateOnAnimation(); } } /** * Stop the animation */ public void stop() { if (isStarted) { isStarted = false; invalidate(); } } }
attr.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="ParallaxView"> <attr name="speed" format="dimension" /> <attr name="src" format="reference" /> </declare-styleable> </resources>
usage:
<com.....ScrollingImageView xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/scrolling_background" android:layout_width="match_parent" android:layout_height="wrap_content" app:speed="1dp" app:src="@drawable/scrolling_background" />
ScrollingImageView scrollingBackground = (ScrollingImageView) loader.findViewById(R.id.scrolling_background); scrollingBackground.stop(); scrollingBackground.start();
Parallax effect:
只要设置不同的滚动背景速率就可以达到视差效果
<FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <com......ScrollingImageView android:id="@+id/scrolling_background" android:layout_width="match_parent" android:layout_height="wrap_content" app:speed="1dp" app:src="@drawable/scrolling_background" /> <com.....ScrollingImageView android:id="@+id/scrolling_foreground" android:layout_width="match_parent" android:layout_height="wrap_content" app:speed="2.5dp" app:src="@drawable/scrolling_foreground" /> </FrameLayout>
发表评论
-
NestedScrollView滚动到顶部固定子View悬停挂靠粘在顶端
2018-10-31 20:45 6781网上有一个StickyScrollView,称之为粘性Scro ... -
自定义Behavior实现AppBarLayout越界弹性效果
2017-03-31 09:33 10208一、继承AppBarLayout.Beha ... -
Android - 一种相似图片搜索算法的实现
2017-03-31 09:33 2563算法 缩小尺寸。 将图片缩小到8x8的尺寸,总共64个 ... -
使用SpringAnimation实现带下拉弹簧动画的 ScrollView
2017-03-30 11:30 2782在刚推出的 Support Library 25.3.0 里面 ... -
Android为应用添加角标(Badge)
2017-03-30 11:21 60911.需求简介 角标是什么意思呢? 看下图即可明了: 可 ... -
Android端与笔记本利用局域网进行FTP通信
2017-03-23 10:17 916先看图 打开前: 打开后: Activity类 ... -
PorterDuffColorFilter 在项目中的基本使用
2017-03-03 10:58 1288有时候标题栏会浮在内容之上,而内容会有颜色的变化,这时候就要求 ... -
ColorAnimationView 实现了滑动Viewpager 时背景色动态变化的过渡效果
2017-02-24 09:41 2162用法在注释中: import android.anima ... -
迷你轻量级全方向完美滑动处理侧滑控件SlideLayout
2017-01-16 16:53 2538纯手工超级迷你轻量级全方向完美滑动处理侧滑控件(比官方 sup ... -
Effect
2017-01-05 09:57 0https://github.com/JetradarMobi ... -
动态主题库Colorful,容易地改变App的配色方案
2016-12-27 14:49 2509Colorful是一个动态主题库,允许您很容易地改变App的配 ... -
对视图的对角线切割DiagonalView
2016-12-27 14:23 1061提供对视图的对角线切割,具有很好的用户定制 基本用法 ... -
仿淘宝京东拖拽商品详情页上下滚动黏滞效果
2016-12-26 16:53 3408比较常用的效果,有现成的,如此甚好!:) import ... -
让任意view具有滑动效果的SlideUp
2016-12-26 09:26 1645基本的类,只有一个: import android.a ... -
AdvancedWebView
2016-12-21 09:44 16https://github.com/delight-im/A ... -
可设置圆角背景边框的按钮, 通过调节色彩明度自动计算按下(pressed)状态颜色
2016-11-02 22:13 1853可设置圆角背景边框的的按钮, 通过调节色彩明度自动计算按下(p ... -
网络请求库相关
2016-10-09 09:35 62https://github.com/amitshekhari ... -
ASimpleCache一个简单的缓存框架
2015-10-26 22:53 2115ASimpleCache 是一个为android制定的 轻量级 ... -
使用ViewDragHelper实现的DragLayout开门效果
2015-10-23 10:55 3325先看一下图,有个直观的了解,向下拖动handle就“开门了”: ... -
保证图片长宽比的同时拉伸图片ImageView
2015-10-16 15:40 3671按比例放大图片,不拉伸失真 import android. ...
相关推荐
在滚动的android ImageView上创建视差和任何其他转换效果
on android ImageView when it's being vertically or horizontally scrolled (moving) on the screen. I wrote an article explaining how this works and implemented, please check it out ...
Parallax Everywhere 扩展了ImageView和TextView,使其具有视差效果。项目地址:https://github.com/Narfss/ParallaxEverywhere 效果图:如何使用:<FrameLayout android:layout_width="0dp" android:...
ScrollParallaxImageView extends ImageView, and provides parallax effects when it scrolls in the screen.It can be use in any view which can scroll its content, like ListView, RecyclerView, ScrollView, ...
Android视差图像视图 当它在屏幕上垂直或水平滚动(移动)时,在android ImageView上创建诸如垂直视差,水平视差等效果。 参考: 截屏设置步骤1将存储库添加到根build.gradle allprojects { repositories { .. . ...
AndroidScrollingImageView一直滚动的ImageView.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
android 自定义属性实现 ImageView 透明度渐变效果
点击图片磁贴效果 很炫.可以玩啊
一个轻量级的iOS 3D线性旋转视差效果
自定义可拖动可缩放的ImageView,通过Matrix和TouchListener实现,随后会加旋转。
可以旋转的ImageView
Android自定义View之仿去哪儿ImageView标签点击效果(指纹和缩放)。
RCImageView 自定义圆角ImageView,带边框效果
(android控件) ImageView 控件开发效果总结 (多组滤镜效果)源码下载
让两个imageView上的图片实现动画互换并且让互换后的Imageview位置也互换
imageView 圆角图片 描边效果
ImageView实现图片跑马灯效果,可以作为学习ImageView使用。
可手势缩放平移及旋转的ImageView。可以直接拿来用。参看博客http://blog.csdn.net/BigBoySunshine/article/details/78256008
这是一款实现了图片视图ImageView走马灯效果源码,功能很容易实现的,源码也简单,具体如效果图所示,大家可以下载看看吧。
1、这是一个支持缩放的ImageView,可直接引入使用