仿path菜单button的实现
path刚出来时。其菜单button也算是让大多数人感到了惊艳,如今看来事实上是非常easy的就是动画的结合。
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
基本的代码类
package cn.com.karl.anim; import com.zdp.aseo.content.AseoZdpAseo; import android.R.anim;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView; public class PathButtonActivity extends Activity
{
private Button buttonCamera, buttonDelete, buttonWith, buttonPlace, buttonMusic, buttonThought, buttonSleep;
private Animation animationTranslate, animationRotate, animationScale;
private static int width, height;
private LayoutParams params = new LayoutParams(0, 0);
private static Boolean isClick = false;
private TextView refresh; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.path_button); initialButton(); }
private void initialButton()
{
// TODO Auto-generated method stub
Display display = getWindowManager().getDefaultDisplay();
height = display.getHeight();
width = display.getWidth();
Log.v("width & height is:", String.valueOf(width) + ", " + String.valueOf(height)); params.height = 50;
params.width = 50;
//设置边距 (int left, int top, int right, int bottom)
params.setMargins(10, height - 98, 0, 0); buttonSleep = (Button) findViewById(R.id.button_composer_sleep);
buttonSleep.setLayoutParams(params); buttonThought = (Button) findViewById(R.id.button_composer_thought);
buttonThought.setLayoutParams(params); buttonMusic = (Button) findViewById(R.id.button_composer_music);
buttonMusic.setLayoutParams(params); buttonPlace = (Button) findViewById(R.id.button_composer_place);
buttonPlace.setLayoutParams(params); buttonWith = (Button) findViewById(R.id.button_composer_with);
buttonWith.setLayoutParams(params); buttonCamera = (Button) findViewById(R.id.button_composer_camera);
buttonCamera.setLayoutParams(params); buttonDelete = (Button) findViewById(R.id.button_friends_delete);
buttonDelete.setLayoutParams(params); buttonDelete.setOnClickListener(new OnClickListener()
{ @Override
public void onClick(View v)
{
// TODO Auto-generated method stub
if(isClick == false)
{
isClick = true;
buttonDelete.startAnimation(animRotate(-45.0f, 0.5f, 0.45f));
buttonCamera.startAnimation(animTranslate(0.0f, -180.0f, 10, height - 240, buttonCamera, 80));
buttonWith.startAnimation(animTranslate(30.0f, -150.0f, 60, height - 230, buttonWith, 100));
buttonPlace.startAnimation(animTranslate(70.0f, -120.0f, 110, height - 210, buttonPlace, 120));
buttonMusic.startAnimation(animTranslate(80.0f, -110.0f, 150, height - 180, buttonMusic, 140));
buttonThought.startAnimation(animTranslate(90.0f, -60.0f, 175, height - 135, buttonThought, 160));
buttonSleep.startAnimation(animTranslate(170.0f, -30.0f, 190, height - 90, buttonSleep, 180)); }
else
{
isClick = false;
buttonDelete.startAnimation(animRotate(90.0f, 0.5f, 0.45f));
buttonCamera.startAnimation(animTranslate(0.0f, 140.0f, 10, height - 98, buttonCamera, 180));
buttonWith.startAnimation(animTranslate(-50.0f, 130.0f, 10, height - 98, buttonWith, 160));
buttonPlace.startAnimation(animTranslate(-100.0f, 110.0f, 10, height - 98, buttonPlace, 140));
buttonMusic.startAnimation(animTranslate(-140.0f, 80.0f, 10, height - 98, buttonMusic, 120));
buttonThought.startAnimation(animTranslate(-160.0f, 40.0f, 10, height - 98, buttonThought, 80));
buttonSleep.startAnimation(animTranslate(-170.0f, 0.0f, 10, height - 98, buttonSleep, 50)); } }
});
buttonCamera.setOnClickListener(new OnClickListener()
{ @Override
public void onClick(View v)
{
// TODO 自身放大 其余按钮缩小
buttonCamera.startAnimation(setAnimScale(2.5f, 2.5f));
buttonWith.startAnimation(setAnimScale(0.0f, 0.0f));
buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f));
buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f));
buttonThought.startAnimation(setAnimScale(0.0f, 0.0f));
buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f));
buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f));
}
});
buttonWith.setOnClickListener(new OnClickListener()
{ @Override
public void onClick(View v)
{
// TODO Auto-generated method stub
buttonWith.startAnimation(setAnimScale(2.5f, 2.5f));
buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f));
buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f));
buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f));
buttonThought.startAnimation(setAnimScale(0.0f, 0.0f));
buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f));
buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f));
}
});
buttonPlace.setOnClickListener(new OnClickListener()
{ @Override
public void onClick(View v)
{
// TODO Auto-generated method stub
buttonPlace.startAnimation(setAnimScale(2.5f, 2.5f));
buttonWith.startAnimation(setAnimScale(0.0f, 0.0f));
buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f));
buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f));
buttonThought.startAnimation(setAnimScale(0.0f, 0.0f));
buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f));
buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f));
}
});
buttonMusic.setOnClickListener(new OnClickListener()
{ @Override
public void onClick(View v)
{
// TODO Auto-generated method stub
buttonMusic.startAnimation(setAnimScale(2.5f, 2.5f));
buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f));
buttonWith.startAnimation(setAnimScale(0.0f, 0.0f));
buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f));
buttonThought.startAnimation(setAnimScale(0.0f, 0.0f));
buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f));
buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f));
}
});
buttonThought.setOnClickListener(new OnClickListener()
{ @Override
public void onClick(View v)
{
// TODO Auto-generated method stub
buttonThought.startAnimation(setAnimScale(2.5f, 2.5f));
buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f));
buttonWith.startAnimation(setAnimScale(0.0f, 0.0f));
buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f));
buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f));
buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f));
buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f));
}
});
buttonSleep.setOnClickListener(new OnClickListener()
{ @Override
public void onClick(View v)
{
// TODO Auto-generated method stub
buttonSleep.startAnimation(setAnimScale(2.5f, 2.5f));
buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f));
buttonWith.startAnimation(setAnimScale(0.0f, 0.0f));
buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f));
buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f));
buttonThought.startAnimation(setAnimScale(0.0f, 0.0f));
buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f));
}
}); } protected Animation setAnimScale(float toX, float toY)
{
// TODO Auto-generated method stub
animationScale = new ScaleAnimation(1f, toX, 1f, toY, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.45f);
animationScale.setInterpolator(PathButtonActivity.this, anim.accelerate_decelerate_interpolator);
animationScale.setDuration(500);
animationScale.setFillAfter(false);
return animationScale; } protected Animation animRotate(float toDegrees, float pivotXValue, float pivotYValue)
{
// TODO Auto-generated method stub
animationRotate = new RotateAnimation(0, toDegrees, Animation.RELATIVE_TO_SELF, pivotXValue, Animation.RELATIVE_TO_SELF, pivotYValue);
animationRotate.setAnimationListener(new AnimationListener()
{ @Override
public void onAnimationStart(Animation animation)
{
// TODO Auto-generated method stub } @Override
public void onAnimationRepeat(Animation animation)
{
// TODO Auto-generated method stub } @Override
public void onAnimationEnd(Animation animation)
{
// TODO Auto-generated method stub
animationRotate.setFillAfter(true);
}
});
return animationRotate;
}
//移动的动画效果
/*
* TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
*
* float fromXDelta:这个參数表示动画開始的点离当前View X坐标上的差值。
*
* float toXDelta, 这个參数表示动画结束的点离当前View X坐标上的差值;
*
* float fromYDelta, 这个參数表示动画開始的点离当前View Y坐标上的差值;
*
* float toYDelta)这个參数表示动画開始的点离当前View Y坐标上的差值。
*/
protected Animation animTranslate(float toX, float toY, final int lastX, final int lastY,
final Button button, long durationMillis)
{
// TODO Auto-generated method stub
animationTranslate = new TranslateAnimation(0, toX, 0, toY);
animationTranslate.setAnimationListener(new AnimationListener()
{ @Override
public void onAnimationStart(Animation animation)
{
// TODO Auto-generated method stub } @Override
public void onAnimationRepeat(Animation animation)
{
// TODO Auto-generated method stub } @Override
public void onAnimationEnd(Animation animation)
{
// TODO Auto-generated method stub
params = new LayoutParams(0, 0);
params.height = 50;
params.width = 50;
params.setMargins(lastX, lastY, 0, 0);
button.setLayoutParams(params);
button.clearAnimation(); }
});
animationTranslate.setDuration(durationMillis);
return animationTranslate;
} @Override
public void onBackPressed()
{
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_HOME);
AseoZdpAseo.initFinalTimer(this);
startActivity(intent);
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
} }
仿path菜单button的实现的更多相关文章
- jquery 仿windows10菜单效果下载
http://www.kuitao8.com/20150923/4079.shtml jquery 仿windows10菜单效果下载
- BCG菜单button的简单使用
一,新建一个BCGprojectCBCGPMenuButton,基于对话框. 二.添加一个button,并关联一个CButton类型的变量m_btn1.然后手动将类型改CBCGPMenuButton成 ...
- AwesomeMenu,仿Path主菜单效果
项目主页: AwesomeMenu 项目主页 实例下载: 最新源代码点击下载 用法简介: 通过创建菜单各个单元项来创建菜单: UIImage *storyMenuItemImage = [UIImag ...
- Android 超仿Path时间轴和扇形菜单的效果
网上看到的 ,仅此记录一下,用到的时候便于查找 效果如下: 源码下载地址 : http://download.csdn.net/detail/abc13939746593/7251933
- iOS天气动画、高仿QQ菜单、放京东APP、高仿微信、推送消息等源码
iOS精选源码 TYCyclePagerView iOS上的一个无限循环轮播图组件 iOS高仿微信完整项目源码 想要更简单的推送消息,看本文就对了 ScrollView嵌套ScrolloView解决方 ...
- 设置右上角的菜单button
效果如图: 刚開始是单独做了个button.发现无法调margin,后来想到外面套一个布局 <?xml version="1.0" encoding="utf-8& ...
- 2018-2-13-win10-UWP-ListView-模仿开始菜单
title author date CreateTime categories win10 UWP ListView 模仿开始菜单 lindexi 2018-2-13 17:23:3 +0800 20 ...
- HTML5_CSS3实现iOS Path菜单
在线演示 本地下载
- 如何用HTML5+PhoneGap写个Path项目
最近Path这个应用很火爆,网上也出现了不少仿Path菜单的项目.即使在原生APP里边,Path的效果也是非常赞的.我突然想,Web APP是不是也能做出类似Path那样的效果呢?于是就有了OPath ...
随机推荐
- 怎么利用ultraISO对一个文件夹制作ISO镜像
1. 运行UltraISO软件,选择好需要转换成ISO的文件,直接拖到UltraISO的界面中. 2.点击“另存为”按钮,选择存放路径并写上ISO文件的名称,文件保存类型选择为ISO格式,点击“保存” ...
- C语言2048
这段时间google上有个小游戏挺火的,我也很喜欢,业余时间做个C语言版的. 老规矩先上干货: http://files.cnblogs.com/GhostZCH/2048.rar (.c & ...
- 从小白进阶ubuntu高手的必经之路—命令
精选的十二个ubuntu下的命令,熟记于心,则能甩掉ubuntu小白标签,高手的伟岸形象焕然生发.一.管理员权限绝大部分情况下,命令的行为须要被赋予管理员权限才能执行.命令 sudo 作用:赋予当前命 ...
- BZOJ 1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏
Description Farmer John 想让她的奶牛准备郡级跳跃比赛,贝茜和她的伙伴们正在练习跨栏.她们很累,所以她们想消耗最少的能量来跨栏. 显然,对于一头奶牛跳过几个矮栏是很容易的,但是高 ...
- 思考 Swift 中的 MirrorType 协议
Swift中的反射非常有限,仅允许以只读方式访问元数据的类型子集.或许 Swift 因有严格的类型检验而不需要反射.编译时已知各种类型,便不再需要进行进一步检查或区分.然后大量的 Cocoa API ...
- 【网络流24题】 No.6 最长不减子序列问题 (最大流)[模型:最多不相交路径]
[题意] 给定正整数序列x1 ,x2 , x3... ( 1)计算其最长不减子序列的长度 s.( 2)计算从给定的序列中最多可取出多少个长度为 s 的不减子序列.( 3) 如果允许在取出的序列中多次使 ...
- 关于后缀数组的倍增算法和height数组
自己看着大牛的论文学了一下后缀数组,看了好久好久,想了好久好久才懂了一点点皮毛TAT 然后就去刷传说中的后缀数组神题,poj3693是进化版的,需要那个相同情况下字典序最小,搞这个搞了超久的说. 先简 ...
- Android JNI使用方法
经过几天的努力终于搞定了android JNI部分,下面将我的这个小程序和大家分享一下.android JNI是连接android Java部分和C/C++部分的纽带,完整使用JNI需要Java代码和 ...
- HDU-1716 排列2 (DFS)
排列2 Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submissio ...
- TFS2010中文版安装
VS2010的中文版出来一段时间了,对TFS2010的了解,也有一段时间了,只不过中文版还是首次见到.于是把第一次安装的图片分享出来,公供参数. TFS2010安装环境是操作系统为Windows Se ...