package com.gallery;
import android.content.Context;
import android.graphics.Camera;
import android.graphics.Matrix;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Transformation;
import android.widget.Gallery;
import android.widget.ImageView;
public class GalleryFlow extends Gallery {
private Camera mCamera = new Camera();
private int mMaxRotationAngle = 60;
private int mMaxZoom = -120;
private int mCoveflowCenter;
public GalleryFlow(Context context) {
super(context);
this.setStaticTransformationsEnabled(true);
}
public GalleryFlow(Context context, AttributeSet attrs) {
super(context, attrs);
this.setStaticTransformationsEnabled(true);
}
public GalleryFlow(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.setStaticTransformationsEnabled(true);
}
public int getMaxRotationAngle() {
return mMaxRotationAngle;
}
public void setMaxRotationAngle(int maxRotationAngle) {
mMaxRotationAngle = maxRotationAngle;
}
public int getMaxZoom() {
return mMaxZoom;
}
public void setMaxZoom(int maxZoom) {
mMaxZoom = maxZoom;
}
private int getCenterOfCoverflow() {
return (getWidth() - getPaddingLeft() - getPaddingRight()) / 2
+ getPaddingLeft();
}
private static int getCenterOfView(View view) {
return view.getLeft() + view.getWidth() / 2;
}
protected boolean getChildStaticTransformation(View child, Transformation t) {
final int childCenter = getCenterOfView(child);
final int childWidth = child.getWidth();
int rotationAngle = 0;
t.clear();
t.setTransformationType(Transformation.TYPE_MATRIX);
if (childCenter == mCoveflowCenter) {
transformImageBitmap((ImageView) child, t, 0);
} else {
rotationAngle = (int) (((float) (mCoveflowCenter - childCenter) / childWidth) * mMaxRotationAngle);
if (Math.abs(rotationAngle) > mMaxRotationAngle) {
rotationAngle = (rotationAngle < 0) ? -mMaxRotationAngle
: mMaxRotationAngle;
}
transformImageBitmap((ImageView) child, t, rotationAngle);
}
return true;
}
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
mCoveflowCenter = getCenterOfCoverflow();
super.onSizeChanged(w, h, oldw, oldh);
}
private void transformImageBitmap(ImageView child, Transformation t,
int rotationAngle) {
mCamera.save();
final Matrix imageMatrix = t.getMatrix();
final int imageHeight = child.getLayoutParams().height;
final int imageWidth = child.getLayoutParams().width;
final int rotation = Math.abs(rotationAngle);
// 在Z轴上正向移动camera的视角,实际效果为放大图片。
// 如果在Y轴上移动,则图片上下移动;X轴上对应图片左右移动。
mCamera.translate(0.0f, 0.0f, 100.0f);
// As the angle of the view gets less, zoom in
if (rotation < mMaxRotationAngle) {
float zoomAmount = (float) (mMaxZoom + (rotation * 1.5));
mCamera.translate(0.0f, 0.0f, zoomAmount);
}
// 在Y轴上旋转,对应图片竖向向里翻转。
// 如果在X轴上旋转,则对应图片横向向里翻转。
mCamera.rotateY(rotationAngle);
mCamera.getMatrix(imageMatrix);
imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));
mCamera.restore();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
gallery(带动画,带页面点击跳转)
共115个文件
xml:62个
png:24个
class:12个
5星 · 超过95%的资源 需积分: 9 136 下载量 12 浏览量
2012-11-28
08:58:52
上传
评论 1
收藏 3.68MB RAR 举报
温馨提示
这个gallery功能很丰富,不仅带有很炫的动画效果,还有页面点击跳转的功能,应用性很强
资源推荐
资源详情
资源评论
收起资源包目录
gallery(带动画,带页面点击跳转) (115个子文件)
jarlist.cache 119B
ImageAdapter.class 5KB
GalleryFlow.class 5KB
ActivityMain.class 3KB
ActivityMain_NEXT.class 3KB
R$anim.class 2KB
R$layout.class 2KB
R$drawable.class 2KB
R.class 1KB
R$id.class 1KB
R$string.class 1KB
R$attr.class 1KB
BuildConfig.class 630B
.classpath 243B
.classpath 243B
GalleryFlow.java 4KB
R.java 3KB
ImageAdapter.java 3KB
ActivityMain_NEXT.java 2KB
ActivityMain.java 1KB
BuildConfig.java 153B
g.png 303KB
g.png 303KB
b.png 283KB
b.png 283KB
d.png 252KB
d.png 252KB
f.png 220KB
f.png 220KB
a.png 179KB
a.png 179KB
e.png 178KB
e.png 178KB
sky.png 161KB
sky.png 161KB
h.png 153KB
h.png 153KB
c.png 141KB
c.png 141KB
icon.png 4KB
icon.png 4KB
icon.png 3KB
icon.png 3KB
icon.png 2KB
icon.png 2KB
org.eclipse.jdt.core.prefs 598B
org.eclipse.jdt.core.prefs 598B
.project 845B
.project 845B
project.properties 360B
project.properties 360B
default.properties 36B
default.properties 36B
layout_gallery_a.xml 1KB
layout_gallery_a.xml 1KB
zoom_exit.xml 1KB
zoom_exit.xml 1KB
hyperspace_out.xml 1KB
hyperspace_out.xml 1KB
zoom_enter.xml 1KB
zoom_enter.xml 1KB
wave_scale.xml 1KB
wave_scale.xml 1KB
layout_gallery_b.xml 1KB
layout_gallery_b.xml 1KB
slide_right.xml 976B
slide_right.xml 976B
slide_left.xml 971B
slide_left.xml 971B
fade.xml 960B
fade.xml 960B
hold.xml 943B
hold.xml 943B
push_up_out.xml 915B
push_up_out.xml 915B
push_up_in.xml 914B
push_up_in.xml 914B
scale_translate_rotate.xml 886B
scale_translate_rotate.xml 886B
hyperspace_in.xml 841B
hyperspace_in.xml 841B
layout_gallery.xml 772B
layout_gallery.xml 772B
my_alpha_action.xml 729B
my_alpha_action.xml 729B
scale_rotate.xml 726B
scale_rotate.xml 726B
AndroidManifest.xml 699B
AndroidManifest.xml 699B
scale_translate.xml 647B
scale_translate.xml 647B
my_scale_action.xml 456B
my_scale_action.xml 456B
layout_gallery_e.xml 285B
layout_gallery_g.xml 285B
layout_gallery_f.xml 285B
layout_gallery_h.xml 285B
layout_gallery_d.xml 285B
layout_gallery_e.xml 285B
layout_gallery_g.xml 285B
共 115 条
- 1
- 2
柳羽禅
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页