求一个android版本的Coverflow

lwlmaomao 2010-11-02 04:55:20
求一个android版本的Coverflow效果的东西,哪位大侠有么?

谢谢!
...全文
218 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
liwy_java 2011-03-02
  • 打赏
  • 举报
回复
楼主,你被骗了,这个代码网上有啊。骗你分的。
Helldance 2010-11-06
  • 打赏
  • 举报
回复
马克,回去试试。
纠结的木棉花 2010-11-05
  • 打赏
  • 举报
回复
package com.example.coverflow;
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 CoverFlow extends Gallery {
/** 036. * Graphics Camera used for transforming the matrix of ImageViews 037. */
private Camera mCamera = new Camera();
/** 041. * The maximum angle the Child ImageView will be rotated by 042. */
private int mMaxRotationAngle = 60;
/** 046. * The maximum zoom on the centre Child 047. */
private int mMaxZoom = -120;
/** 051. * The Centre of the Coverflow 052. */
private int mCoveflowCenter;
public CoverFlow(Context context) {
super(context);
this.setStaticTransformationsEnabled(true);
}
public CoverFlow(Context context, AttributeSet attrs) { super(context, attrs);
this.setStaticTransformationsEnabled(true);
}
public CoverFlow(Context context, AttributeSet attrs, int defStyle)
{ super(context, attrs, defStyle);
this.setStaticTransformationsEnabled(true);
}
/** 071. * Get the max rotational angle of the image 072. *
* @return the mMaxRotationAngle 073. */
public int getMaxRotationAngle() {
return mMaxRotationAngle;
}
/** 079. * Set the max rotational angle of each image 080. *
* @param maxRotationAngle the mMaxRotationAngle to set 081. */
public void setMaxRotationAngle(int maxRotationAngle)
{ mMaxRotationAngle = maxRotationAngle; }
/** 087. * Get the Max zoom of the centre image 088.
* * @return the mMaxZoom 089. */
return mMaxZoom;
}
/** 095. * Set the max zoom of the centre image 096. *
* @param maxZoom the mMaxZoom to set 097. */
public void setMaxZoom(int maxZoom)
{ mMaxZoom = maxZoom;
/** 103. * Get the Centre of the Coverflow 104. *
* @return The centre of this Coverflow. 105. */
private int getCenterOfCoverflow() {
return (getWidth() - getPaddingLeft() - getPaddingRight()) / 2 + getPaddingLeft(); 108. } 109. 110. /** 111. * Get the Centre of the View 112. * @return The centre of the given view. 113. */ 114.
private static int getCenterOfView(View view)
{ return view.getLeft() + view.getWidth() / 2;
}
/** 118. * {@inheritDoc} 119. * 120. *
* @see #setStaticTransformationsEnabled(boolean)
*/
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;
}
/** 145. * This is called during layout when the size of this view has changed.
* If 146. * you were just added to the view hierarchy,
* you're called with the old 147. * values of 0. 148. * 149.
* * @param w Current width of this view. 150. *
* @param h Current height of this view. 151. *
* @param oldw Old width of this view. 152. *
* @param oldh Old height of this view. 153. */
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
mCoveflowCenter = getCenterOfCoverflow();
super.onSizeChanged(w, h, oldw, oldh);
}
/** 160. * Transform the Image Bitmap by the Angle passed 161. *
* 162. * @param imageView ImageView the ImageView whose bitmap we want to
* rotate 163. * @param t transformation 164. * @param rotationAngle the
* Angle by which to rotate the Bitmap 165. */
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);
mCamera.translate(0.0f, 0.0f, 100.0f);
//As the angle of the view gets less, zoom in 176.
if ( rotation < mMaxRotationAngle )
{
float zoomAmount = (float) (mMaxZoom + (rotation * 1.5));
mCamera.translate(0.0f, 0.0f, zoomAmount); }
mCamera.rotateY(rotationAngle);
mCamera.getMatrix(imageMatrix);
imageMatrix.preTranslate(-(imageWidth/2), -(imageHeight/2));
imageMatrix.postTranslate((imageWidth/2), (imageHeight/2));
mCamera.restore(); }
}
}
}
lwlmaomao 2010-11-02
  • 打赏
  • 举报
回复
呵呵,DrSmart兄,加分好说,你给我一个,我绝对给你加分
DrSmart 2010-11-02
  • 打赏
  • 举报
回复
gallery改造下就行了,你要3d的,可能我要花点时间,你加点分,我给你个

80,350

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧