PathButton.zip

  • PUDN用户
    了解作者
  • Java
    开发工具
  • 63KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 9
    下载次数
  • 2013-12-10 09:11
    上传日期
android动画,点击按钮,弹出相关的小按钮
PathButton.zip
内容介绍
package wgw.temp.test; import android.R.anim; import android.app.Activity; 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; 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; /** 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; 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, 170, height - 140, buttonThought, 160)); buttonSleep.startAnimation(animTranslate(170.0f, -30.0f, 180, height - 100, 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 Log.v("shifoudianji", "YES"); 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 pivotYVal
评论
    相关推荐
    • AndroidSample
      Android示例 这是一个示例Android应用,用于降低Google Play服务和Android Volley的使用率。 有关更多详细信息,请参阅以下链接: Google Play服务: Android凌空抽射:
    • Android开发
      什么是Android,搭建Android开发环境,第一个Android程序
    • android 日历
      android 日历 android 日历 android 日历 android 日历
    • android课件
      android课件,传到网上供大家分享,希望对你们有帮助。
    • android wps
      android wps android wps android wps android wps android wps android wps
    • Android API
      API文档(Reference)是Android开发的基础,三年来(2007-2010)官方仍未出中文版的API,Android中文翻译组聚一批从事Android开发人员、论坛版主、大学生、研究生等利用业余时间对Android的API进行翻译,人数从1人到80+...
    • android source
      android 源代码 source android 源代码 source android 源代码 source android 源代码 source android 源代码 source android 源代码 source android 源代码 source
    • androidHook
      androidHook,xposed,Android逆向androidHook,xposed,Android逆向
    • Android 教程
      Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android 案例 教程,Android ...
    • android资料
      Android程序员指南 Android_UI开发专题 Android程序开发初级教程 android的五大类各种常用类的资料整理 Android高手进阶教程