旋转gallery
来源:互联网 发布:自制单片机小说阅读器 编辑:程序博客网 时间:2024/04/29 09:04
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);
- 旋转gallery
- 2010.06.05日志:Android Gallery左右循环旋转方法
- Android gallery实现图片的左右循环旋转源码分享
- Android gallery实现图片的左右循环旋转源码分享
- Android gallery实现图片的左右循环旋转源码分享
- Android gallery实现图片的左右循环旋转源码分享
- Gallery
- Gallery
- Gallery
- gallery
- gallery
- Gallery
- gallery
- Gallery
- Gallery
- Gallery
- Gallery
- Gallery
- 记上面的js,整合出可以用的用户控件(asp.net方面)
- 海量空间数据库实施策略---矢量数据6
- C++学习----类模板
- 文件系统摘要
- ie下载 txt文件的解决方法
- 旋转gallery
- 富兰克林与他的13条完美道德准则(为了更顺畅,加了点内容。)
- linux命令别名(linux command alias)
- ISAG 网关接收上行消息和接收订购指令
- eclipse 自动补全的设置,不用按 alt-/ 了
- Windows下JNI生成头文件
- 求佳宜进销存
- eclipse 自动补全的设置,不用按 alt-/ 了
- Windows GDI和GDI+编程实例剖析 (1)