android版的path2.0菜单功能实现源码免费下载
path2.0的动态菜单确实很炫,可是在网上没找的android版本,于是就自己实现了一下。感觉效果还可以,就分享出来让大家一起来改进。最终希望能实现iphone上那种效果。效果图如下:
废话少说,见源码:
package com.path.demo;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.TranslateAnimation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
public class TestPathActivity extends Activity implements OnClickListener{
private ImageView ivComposer;
private RotateAnimation clockwiseAm;
private RotateAnimation anticlockwiseAm;
private ImageView ivCamera;
private TranslateAnimation cameraOutTA;//相机
private TranslateAnimation cameraInTA;
private ImageView ivWith;
private TranslateAnimation withOutTA;
private TranslateAnimation withInTA;
private ImageView ivPlace;
private TranslateAnimation placeOutTA;
private TranslateAnimation placeInTA;
private ImageView ivMusic;
private TranslateAnimation musicOutTA;
private TranslateAnimation musicInTA;
private ImageView ivThought;
private TranslateAnimation thoughtOutTA;
private TranslateAnimation thoughtInTA;
private ImageView ivSleep;
private TranslateAnimation sleepOutTA;
private TranslateAnimation sleepInTA;
// am = new RotateAnimation ( 0, 360, 13, 13 );
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.ivComposer:
if(isClockwise){
ivComposer.startAnimation(clockwiseAm);
ivCamera.startAnimation(cameraOutTA);
ivCamera.setVisibility(View.VISIBLE);
withOutTA.setStartOffset(20);
ivWith.startAnimation(withOutTA);
ivWith.setVisibility(View.VISIBLE);
placeOutTA.setStartOffset(40);
ivPlace.startAnimation(placeOutTA);
ivPlace.setVisibility(View.VISIBLE);
musicOutTA.setStartOffset(60);
ivMusic.startAnimation(musicOutTA);
ivMusic.setVisibility(View.VISIBLE);
thoughtOutTA.setStartOffset(80);
ivThought.startAnimation(thoughtOutTA);
ivThought.setVisibility(View.VISIBLE);
sleepOutTA.setStartOffset(100);
ivSleep.startAnimation(sleepOutTA);
ivSleep.setVisibility(View.VISIBLE);
}else{
ivComposer.startAnimation(anticlockwiseAm);
ivSleep.startAnimation(sleepInTA);
ivSleep.setVisibility(View.GONE);
thoughtInTA.setStartOffset(20);
ivThought.startAnimation(thoughtInTA);
ivThought.setVisibility(View.GONE);
musicInTA.setStartOffset(40);
ivMusic.startAnimation(musicInTA);
ivMusic.setVisibility(View.GONE);
placeInTA.setStartOffset(60);
ivPlace.startAnimation(placeInTA);
ivPlace.setVisibility(View.GONE);
withInTA.setStartOffset(80);
ivWith.startAnimation(withInTA);
ivWith.setVisibility(View.GONE);
cameraInTA.setStartOffset(100);
ivCamera.startAnimation(cameraInTA);
ivCamera.setVisibility(View.GONE);
}
break;
case R.id.ivCamera:
break;
case R.id.ivWith:
break;
case R.id.ivPlace:
break;
case R.id.ivThought:
break;
case R.id.ivMusic:
break;
case R.id.ivSleep:
break;
}
}
private boolean isClockwise = true;
private AnimationListener clockwiseAmListener = new AnimationListener() {
public void onAnimationEnd(Animation arg0) {
Matrix matrix = new Matrix();
matrix.setRotate(45);
Bitmap source = BitmapFactory.decodeResource(TestPathActivity.this.getResources(), R.drawable.composer_icn_plus);
Bitmap resizedBitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
ivComposer.setImageBitmap(resizedBitmap);
if(source!=null && !source.isRecycled())
source.recycle();
isClockwise = false;
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
};
private AnimationListener anticlockwiseAmListener = new AnimationListener() {
public void onAnimationEnd(Animation arg0) {
Bitmap source = BitmapFactory.decodeResource(TestPathActivity.this.getResources(), R.drawable.composer_icn_plus);
ivComposer.setImageBitmap(source);
isClockwise = true;
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
};
}
-------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
</manifest>
作者微博:weibo.com/aizhimin
android版的path2.0菜单功能源码免费下载:http://www.elian.me/app/download/file/view/435