• 大小: 196KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-21
  • 语言: Java
  • 标签: android  

资源简介

android 幻灯片效果,android 幻灯片效果

资源截图

代码片段和文件信息

package com.open.turnpage;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.Rect;
import android.view.SurfaceHolder;

/**
 * 
 * @author yanglonghui
 *
 */
public class BlackSquareFadeAway implements ITurnPage {

private int duration=850;//动画持续时间
private final int leafNum=5;
private PaintFlagsDrawFilter pdf=new PaintFlagsDrawFilter(0 Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG);

public BlackSquareFadeAway() {
// TODO Auto-generated constructor stub
}

@Override
public void onCreate() {
// TODO Auto-generated method stub

}

@Override
public void onTurnPageDraw(SurfaceHolder holder Bitmap[] bitmap
int maxWidth int maxHeight) {

int dx=(maxWidth-bitmap[0].getWidth())/2;
int dy=(maxHeight-bitmap[0].getHeight())/2;
int perWidth=maxWidth/leafNum;
int row=maxHeight/perWidth;
int perHeight=maxHeight/row;

Rect[][] array=new Rect[row][leafNum];
for(int i=0;i {
for(int j=0;j {
array[i][j]=new Rect();
array[i][j].set(j*perWidth i*perHeight (j+1)*perWidth (i+1)*perHeight);

if(j==array[i].length-1)
{
array[i][j].set(maxWidth-perWidth array[i][j].top maxWidth array[i][j].bottom);
}

if(i==array.length-1)
{
array[i][j].set(array[i][j].left maxHeight-perHeight array[i][j].right maxHeight);
}
}
}

long start=System.currentTimeMillis();
long runMills=0;


Paint mRectPaint=new Paint();
mRectPaint.setColor(Color.BLACK);
Rect drawRect=new Rect();

Canvas canvas=null;
boolean isRunning=true;
while(isRunning)
{
isRunning=((runMills=(System.currentTimeMillis()-start)) if(!isRunning)
{
runMills=duration;
}

try {
canvas=holder.lockCanvas(null);

canvas.setDrawFilter(pdf);
canvas.drawColor(Color.BLACK);// 清除画布

if(!isRunning)
{
canvas.drawBitmap(bitmap[0] dx dy null);
}
else
{
canvas.save();
canvas.translate(dx dy);
for(int i=0;i {
for(int j=0;j {
drawRect.set(array[i][j]);
int _dx = drawRect.width()/2-(int)(((float)runMills/(float)duration)*drawRect.width()/2);
int _dy = drawRect.height()/2-(int)(((float)runMills/(float)duration)*drawRect.height()/2);

drawRect.inset(_dx _dy);
canvas.drawBitmap(bitmap[0] drawRect drawRect null);
}
}
canvas.restore();
}
} catch (Exception e) {
e.printStackTrace();
}finally{
if(null!=canvas)
{
holder.unlockCanvasAndPost(canvas);
}
else
{
break;
}

if(!isRunning)
{
break;
}
}
}
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-12-14 15:24  android-turnpage-master\
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\
     文件         475  2013-12-14 15:24  android-turnpage-master\git_turnpage\.classpath
     文件         848  2013-12-14 15:24  android-turnpage-master\git_turnpage\.project
     文件         481  2013-12-14 15:24  android-turnpage-master\git_turnpage\AndroidManifest.xml
     文件         781  2013-12-14 15:24  android-turnpage-master\git_turnpage\proguard-project.txt
     文件         584  2013-12-14 15:24  android-turnpage-master\git_turnpage\project.properties
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\drawable-hdpi\
     文件        9397  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\drawable-hdpi\ic_launcher.png
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\drawable-mdpi\
     文件        5237  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\drawable-mdpi\ic_launcher.png
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\drawable-xhdpi\
     文件       14383  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\drawable-xhdpi\ic_launcher.png
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\values-v11\
     文件         334  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\values-v11\styles.xml
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\values-v14\
     文件         391  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\values-v14\styles.xml
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\values\
     文件          82  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\values\strings.xml
     文件         697  2013-12-14 15:24  android-turnpage-master\git_turnpage\res\values\styles.xml
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\com\
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\com\open\
     目录           0  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\com\open\turnpage\
     文件        3108  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\com\open\turnpage\BlackSquareFadeAway.java
     文件        2898  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\com\open\turnpage\BlackSquareZoomIn.java
     文件         381  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\com\open\turnpage\ITurnPage.java
     文件        2064  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\com\open\turnpage\ShutterDown2Up.java
     文件        2194  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\com\open\turnpage\ShutterLeft2Right.java
     文件        1992  2013-12-14 15:24  android-turnpage-master\git_turnpage\src\com\open\turnpage\ShutterRight2Left.java
............此处省略38个文件信息

评论

共有 条评论