首页 > 程序开发 > 移动开发 > Android >

android 幻灯片效果之小方块渐入渐出

2013-12-16

实现原理: 使用SurfaceView一直重绘实现该动画效果 先看效果图: 代码实现: a,黑块渐渐消失,最后显示图片 package com open turnpage; import android graphics Bitmap; import android graphics

实现原理:

使用SurfaceView一直重绘实现该动画效果

先看效果图:

height=677height=676

代码实现:

a,黑块渐渐消失,最后显示图片

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 BlackSquareZoomIn 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 BlackSquareZoomIn() {
		// 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

b,图片以方块渐渐显示

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

相关文章
最新文章
热点推荐