很炫的Button效果_wpf 玻璃按钮_攻城狮!的博客-程序员秘密

技术标签: 很炫的Button效果  

PathButtonActivity

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);
        
        refresh=(TextView) this.findViewById(R.id.refresh);
        refresh.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent=new Intent(PathButtonActivity.this,MainActivity.class);
				startActivity(intent);
				//第一个参数为启动时动画效果,第二个参数为退出时动画效果
				overridePendingTransition(R.anim.fade, R.anim.hold);
			}
		});
        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 Auto-generated method stub	
				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));
				Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
				startActivity(intent);
			}
		});
		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();
}
		
}

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/wuxin782515516/article/details/46563043

智能推荐

OpenGL的填充属性函数之线框图方法的改进_iteye_17686的博客-程序员秘密

OpenGL的填充属性函数之———线框图方法的改进对于一个三维多边形来说,上一篇中显示填充多边形边的方法可能在边之间生成缝隙。这种称为缝线的效果由扫描线填充算法和边的画线算法的计算差别造成的。消除三维多边形显示边的缝隙的一个办法是移动由填充子程序计算的深度值,使他们与多边形的边的深度值不重叠。红色字体为重点:代码如下所示:#include <windows.h>...

LeetCode刷题进阶之合并两个有序链表(21)/合并两个排序的链表(剑指Offer 25)_Hard Coder的博客-程序员秘密

一、题目二、测试代码解法一:递归1、终止条件:两条链表分别名为 l1 和 l2,当 l1 为空或 l2 为空时结束;2、返回值:每一层调用都返回排序好的链表头;3、递归内容:如果 l1 的 val 值更小,则将 l1.next 与排序好的链表头相接,l2 同理。/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListN

9行代码实现ssh多个服务器执行相同命令_一台服务器启动其他服务器相同的脚本_刘大大__的博客-程序员秘密

在工作中大家肯定遇到过要进入不同的服务器执行命令,这个脚本实现了进入不同服务器执行相同命令,节省了大量的时间。脚本如下所示:#!/bin/bashFILE_LIST=/opt/myshell/listCMD=$1NAME=$2for IP in `cat $FILE_LIST|grep -v '^#'|grep "|$NAME" |awk -F'|' '{print $1}'`do echo "--------------------$IP------------------ "

Ubuntu系统下载(清华大学开源软件镜像站)(ubuntu-20.04.1-desktop-amd64.iso)_-借我杀死庸碌的情怀-的博客-程序员秘密

清华大学开源网站镜像站网址:https://mirrors.tuna.tsinghua.edu.cn/进入之后在搜索框中搜索“ubuntu”

解决ScrollView嵌套RecyclerView只显示一行的一种比较简单的方法_AkersMan的博客-程序员秘密

解决ScrollView嵌套RecyclerView只显示一行的一种比较简单的方法ScrollView嵌套RecyclerView用多了,有些时候就会发现RecyclerView的数据只显示一行。具体情况不是很清楚,只是知道一种解决的办法,话不多说 <RelativeLayout android:layout_width="mat

一个正整数分解为几个连续的正整数之和_梓逸宸的博客-程序员秘密

题目: 给定你一个数字 如:15 15可分解为7+84+5+61+2+3+4+5再如:88不可分解为任何连续的正整数之和所以输出NONE此题就是给定一个数字如果这个数字可以分解为几个连续的正整数之和那么就输出所有的形式,如果不能就输出NONE今天这道题困扰了我好久,最后发现,一开始求和的时候算错了。 输入数n,设置起始位置i,再遍历连续正整数的长度k,由公式计算出 s

随便推点

ARCGIS中某字段递增赋值_gis递增数字代码_Andy是个男子名的博客-程序员秘密

ARCGIS中某字段递增赋值在地段计算器中使用一下代码:rec=0def autoIncrement(): global rec pStart = 1 pInterval = 1 if (rec == 0): rec = pStart else: rec = rec + pInterval return rec然后在字段里输入autoIncrement(...

http和tcp以及websocket协议_websocket http tcp_MarryOnlyQueen的博客-程序员秘密

解析常见的协议TCP/IP协议HTTP协议什么是超文本什么是传输什么是协议优点总结HTTPSSSL/TLS协议分层模型TCP/IPOSI一个HTTP的请求过程二层转发以及三层路由HTTP/1HTTP/1.0HTTP/1.1队头阻塞问题HTTP/2websocket特性TCP/IP协议三次握手和四次挥手三次握手第一次握手:建立连接时,客户端发送syn包(syn=j)到服务器,并进入SYN_SENT状态,等待服务器确认;SYN:同步序列编号(Synchronize Sequence Numbers

ODOO11开发手册_yanhaiwang的博客-程序员秘密

今看到一篇ODOO11开发文档,希望能够分享给大家。原文地址http://www.docin.com/DocinViewer-2137881329-144.swf

音频编解码_音乐解码_一摩尔自由的博客-程序员秘密

https://www.cnblogs.com/skyofbitbit/p/3651270.htmlhttps://www.cnblogs.com/imstudy/p/10289944.html音频编解码常用的实现方案有三 种: 第一种就是采用专用的音频芯片对 语音信号进行采集和处理,音频编解码算法集成在硬件内部,如MP3编解码芯片、语音合成 分析芯片等。使用这种方案的优点就...

nginx php 静态化,nginx下WordPress伪静态化与静态化_城闭喧的博客-程序员秘密

在强大的模板、插件的支持下,WordPress从一个博客后台工具,直接升级为CMS内容发布系统,已经是没有任何疑义的一个事实。但是WordPress的文章链接,以xxx.xxx.xxx.xxx/?p=123之类的形式存在,对于网站的SEO来说,确实是不太友好。对于这个问题,其实wordpress本身是有支持的。在wordpress里,链接地址可以是“固定链接”的形式。这种形式,我们很多时候称它为“...

RPC框架对比_Bagba的博客-程序员秘密

由于项目需要,准备开发一个分布式限速服务,参考:分布式限速,会应用到RPC服务,所以需要先调研主流RPC服务的性能,可靠,易用性。Go RPCgolang原生的rpc服务GRPC底层协议基于HTTP2RPCX...

推荐文章

热门文章

相关标签