按钮点击,弹出三个按钮

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.z.testz.fangmeipuxiaoguo.FangmeipuActivity">

    <!--<RelativeLayout

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@color/colorAccent"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        >-->

        <ImageView
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            android:id="@+id/icon1"
            android:src="@drawable/shizi"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        <ImageView
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            android:id="@+id/icon2"
            android:src="@drawable/shizi"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        <ImageView
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            android:id="@+id/icon3"
            android:src="@drawable/shizi"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        <ImageView
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            android:id="@+id/imagebutton_bottom"
            android:src="@drawable/shizi"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
   <!-- </RelativeLayout>-->

</RelativeLayout>
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.AppCompatButton;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.AnticipateInterpolator;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.z.testz.R;

public class FangmeipuActivity extends AppCompatActivity {

    private ImageView button;
    private int count= 0;
    private ImageView icon1;
    private ImageView icon2;
    private ImageView icon3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fangmeipu);

        button = (ImageView) findViewById(R.id.imagebutton_bottom);
        icon1 = (ImageView) findViewById(R.id.icon1);
        icon2 = (ImageView) findViewById(R.id.icon2);
        icon3 = (ImageView) findViewById(R.id.icon3);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(count%2==0){
                    open();
                    openMain();
                    count++;
                } else{
                    close();
                    closeMain();
                    count++;
                }

            }
        });

        icon1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                close();
                closeMain();
                count=0;
                Toast.makeText(FangmeipuActivity.this, "按钮1被选择了", Toast.LENGTH_SHORT).show();
            }
        });
        icon2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                close();
                count=0;
                closeMain();
                Toast.makeText(FangmeipuActivity.this, "按钮2被选择了", Toast.LENGTH_SHORT).show();
            }
        });
        icon3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                close();
                closeMain();
                count=0;
                Toast.makeText(FangmeipuActivity.this, "按钮3被选择了", Toast.LENGTH_SHORT).show();
            }
        });

    }
        private void openMain() {
            ObjectAnimator anim = ObjectAnimator.ofFloat(button, "rotation", 0f, 90f);
            anim.setDuration(1000);
            anim.setRepeatMode(ValueAnimator.RESTART);

            anim.setRepeatCount(0);
            anim.start();
        }
        private void closeMain() {
            ObjectAnimator anim = ObjectAnimator.ofFloat(button, "rotation", 0f, -90f);
            anim.setDuration(1000);
            anim.setRepeatMode(ValueAnimator.RESTART);

            anim.setRepeatCount(0);
            anim.start();
        }
        private void open() {

        ObjectAnimator icon1Anim_scaley=ObjectAnimator.ofFloat(icon1,"scaleY",0.1f,0,0.5f,1);
        icon1Anim_scaley.setDuration(1000);
        icon1Anim_scaley.setRepeatCount(0);
        icon1Anim_scaley.setRepeatMode(ValueAnimator.RESTART);
        icon1Anim_scaley.start();
        ObjectAnimator icon1Anim_scalex=ObjectAnimator.ofFloat(icon1,"scaleX",0.1f,0,0.5f,1);
        icon1Anim_scalex.setDuration(1000);
        icon1Anim_scalex.setRepeatCount(0);
        icon1Anim_scalex.setRepeatMode(ValueAnimator.RESTART);
        icon1Anim_scalex.start();
        ObjectAnimator icon1Anim=ObjectAnimator.ofFloat(icon1,"translationY",-300);
        icon1Anim.setDuration(1000);
        icon1Anim.setRepeatMode(ValueAnimator.RESTART);
        icon1Anim.setRepeatCount(0);
        icon1Anim.start();

        ObjectAnimator icon2Anim=ObjectAnimator.ofFloat(icon2,"translationY",-300);
        ObjectAnimator icon2Anim_x=ObjectAnimator.ofFloat(icon2,"translationX",-300);
        icon2Anim.setDuration(1000);
        icon2Anim_x.setDuration(1000);
        icon2Anim.setRepeatMode(ValueAnimator.RESTART);
        icon2Anim_x.setRepeatMode(ValueAnimator.RESTART);
        icon2Anim.setRepeatCount(0);
        icon2Anim_x.setRepeatCount(0);
        icon2Anim.start();
        icon2Anim_x.start();
        ObjectAnimator icon2Anim_scaley=ObjectAnimator.ofFloat(icon2,"scaleY",0.1f,0,0.5f,1);
        icon2Anim_scaley.setDuration(1000);
        icon2Anim_scaley.setRepeatCount(0);
        icon2Anim_scaley.setRepeatMode(ValueAnimator.RESTART);
        icon2Anim_scaley.start();
        ObjectAnimator icon2Anim_scalex=ObjectAnimator.ofFloat(icon2,"scaleX",0.1f,0,0.5f,1);
        icon2Anim_scalex.setDuration(1000);
        icon2Anim_scalex.setRepeatCount(0);
        icon2Anim_scalex.setRepeatMode(ValueAnimator.RESTART);
        icon2Anim_scalex.start();

        ObjectAnimator icon3Anim=ObjectAnimator.ofFloat(icon3,"translationY",-300);
        ObjectAnimator icon3Anim_x=ObjectAnimator.ofFloat(icon3,"translationX",300);
        icon3Anim.setDuration(1000);
        icon3Anim_x.setDuration(1000);
        icon3Anim.setRepeatMode(ValueAnimator.RESTART);
        icon3Anim_x.setRepeatMode(ValueAnimator.RESTART);
        icon3Anim.setRepeatCount(0);
        icon3Anim_x.setRepeatCount(0);
        icon3Anim.start();
        icon3Anim_x.start();
        ObjectAnimator icon3Anim_scaley=ObjectAnimator.ofFloat(icon3,"scaleY",0.1f,0,0.5f,1);
        icon3Anim_scaley.setDuration(1000);
        icon3Anim_scaley.setRepeatCount(0);
        icon3Anim_scaley.setRepeatMode(ValueAnimator.RESTART);
        icon3Anim_scaley.start();
        ObjectAnimator icon3Anim_scalex=ObjectAnimator.ofFloat(icon3,"scaleX",0.1f,0,0.5f,1);
        icon3Anim_scalex.setDuration(1000);
        icon3Anim_scalex.setRepeatCount(0);
        icon3Anim_scalex.setRepeatMode(ValueAnimator.RESTART);
        icon3Anim_scalex.start();

    }
    private void close() {
        ObjectAnimator icon1Anim_scaley=ObjectAnimator.ofFloat(icon1,"scaleY",1,1,0.5f,0);
        icon1Anim_scaley.setDuration(1000);
        icon1Anim_scaley.setRepeatCount(0);
        icon1Anim_scaley.setRepeatMode(ValueAnimator.RESTART);
        icon1Anim_scaley.start();
        ObjectAnimator icon1Anim_scalex=ObjectAnimator.ofFloat(icon1,"scaleX",1,1,0.5f,0);
        icon1Anim_scalex.setDuration(1000);
        icon1Anim_scalex.setRepeatCount(0);
        icon1Anim_scalex.setRepeatMode(ValueAnimator.RESTART);
        icon1Anim_scalex.start();
        ObjectAnimator icon1Anim=ObjectAnimator.ofFloat(icon1,"translationY",0);
        icon1Anim.setDuration(1000);
        icon1Anim.setRepeatMode(ValueAnimator.RESTART);
        icon1Anim.setRepeatCount(0);
        icon1Anim.start();

        ObjectAnimator icon2Anim=ObjectAnimator.ofFloat(icon2,"translationY",0);
        ObjectAnimator icon2Anim_x=ObjectAnimator.ofFloat(icon2,"translationX",0);
        icon2Anim.setDuration(1000);
        icon2Anim_x.setDuration(1000);
        icon2Anim.setRepeatMode(ValueAnimator.RESTART);
        icon2Anim_x.setRepeatMode(ValueAnimator.RESTART);
        icon2Anim.setRepeatCount(0);
        icon2Anim_x.setRepeatCount(0);
        icon2Anim.start();
        icon2Anim_x.start();
        ObjectAnimator icon2Anim_scaley=ObjectAnimator.ofFloat(icon2,"scaleY",1,1,0.5f,0);
        icon2Anim_scaley.setDuration(1000);
        icon2Anim_scaley.setRepeatCount(0);
        icon2Anim_scaley.setRepeatMode(ValueAnimator.RESTART);
        icon2Anim_scaley.start();
        ObjectAnimator icon2Anim_scalex=ObjectAnimator.ofFloat(icon2,"scaleX",1,1,0.5f,0);
        icon2Anim_scalex.setDuration(1000);
        icon2Anim_scalex.setRepeatCount(0);
        icon2Anim_scalex.setRepeatMode(ValueAnimator.RESTART);
        icon2Anim_scalex.start();

        ObjectAnimator icon3Anim=ObjectAnimator.ofFloat(icon3,"translationY",0);
        ObjectAnimator icon3Anim_x=ObjectAnimator.ofFloat(icon3,"translationX",0);
        icon3Anim.setDuration(1000);
        icon3Anim_x.setDuration(1000);
        icon3Anim.setRepeatMode(ValueAnimator.RESTART);
        icon3Anim_x.setRepeatMode(ValueAnimator.RESTART);
        icon3Anim.setRepeatCount(0);
        icon3Anim_x.setRepeatCount(0);
        icon3Anim.start();
        icon3Anim_x.start();
        ObjectAnimator icon3Anim_scaley=ObjectAnimator.ofFloat(icon3,"scaleY",1,1,0.5f,0);
        icon3Anim_scaley.setDuration(1000);
        icon3Anim_scaley.setRepeatCount(0);
        icon3Anim_scaley.setRepeatMode(ValueAnimator.RESTART);
        icon3Anim_scaley.start();
        ObjectAnimator icon3Anim_scalex=ObjectAnimator.ofFloat(icon3,"scaleX",1,1,0.5f,0);
        icon3Anim_scalex.setDuration(1000);
        icon3Anim_scalex.setRepeatCount(0);
        icon3Anim_scalex.setRepeatMode(ValueAnimator.RESTART);
        icon3Anim_scalex.start();

    }

}
时间: 2024-12-17 00:14:49

按钮点击,弹出三个按钮的相关文章

点击datagrid弹出ldhdialog,点击弹出框的按钮,关闭且刷新datagrid

datagrid里的js这么写 //点击添加按钮触发 function superadd(title,addurl,gname,width,height) { gridname=gname; createwindow(title, addurl,width,height); }//点击修改按钮触发function superupdate(title,url, id,width,height,isRestful) { gridname=id; var rowsData = $('#'+id).da

模仿汽车大全的点击一个按钮,会弹出多个按钮,同时,点击背景图,多个按钮动画返回的效果

刚开始运行的时候的效果图: 点击ican图标后的效果图: RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController { UIImageView *iCanImageView; UIImageView *menu_carImageView; UIImageView *menu_movieImageView; UIImageView *menu_setImageView

android 开发点击弹出对话框中的按钮进行页面跳转如何实现

android开发中,点击弹出对话框中的按钮进行页面跳转,如何实现?可以这样做: 可以获取对话框的点击事件,比如点击了确定然后你就跳转 AlertDialog.Builder builder = new Builder(CommentActivity.this); builder.setMessage("确定要跳转吗?"); builder.setTitle("提示"); builder.setPositiveButton("确认", new a

吴裕雄 Bootstrap 前端框架开发——Bootstrap 按钮:用于要弹出信息的按钮

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css"

监听按钮点击事件的三种方式实现及调试信息输出的三种方式实现

监听按钮点击事件的三种方式实现: 1.匿名内部类 2.外部独立类 3.接口实现 package com.example.button; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View;

Unity NGUI监听按钮点击事件的三种方法

NGUI版本:3.6.5 1.直接实现OnClick方法: 创建一个脚本,在脚本中实现OnClick()方法,绑定该脚本到按钮上,点击时就会实现OnClick函数内容: 2.使用SendMessage: 选择按钮后,打开Component——NGUI——Interaction,选择Button Message,为按钮添加一个UIButton Message组件: 然后设置UIButton Message中的参数即可: Target:接收按钮消息的游戏对象: Function Name:接收按钮消

点击弹出居中带有透明遮罩层窗口

点击弹出居中带有透明遮罩层窗口:本章节介绍一下如何点击一个按钮实现弹出一个居中窗口,并且此窗口带有半透明的遮罩层效果,此效果在当下比较流行,当然还有更为复杂的实现方式,当然效果也更为绚丽,下面介绍的代码能够简单实现此效果.代码如下: <!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="htt

经验总结:WebBrowser自动点击弹出提示框alert、弹出对话框confirm、屏蔽弹出框、屏蔽弹出脚本错误的解决办法

经验总结:WebBrowser自动点击弹出提示框alert.弹出对话框confirm.屏蔽弹出框.屏蔽弹出脚本错误的解决办法 网上有好多解决方法,可是不一定好使,本人经过多次试验,针对WebBrowser控件中自动点击弹出框及禁用脚本提示问题得到如下几种实际情况的解决办法,绝对管用. 1.屏蔽弹出错误脚本 将WebBrowser控件ScriptErrorsSuppressed设置为True即可. (参考本篇博客:http://www.cnblogs.com/qqflying/archive/20

点击弹出带有确定和取消选项的提示框

点击弹出带有确定和取消选项的提示框: 这种效果你可能遇到过,那就是点击一个按钮(并非必须是按钮,只是一个例子而已)的时候,会弹出一个提示框,这个提示框带有确定和取消按钮,点击确定就可以执行相应的操作,点击取消的话就取消操作.下面看一个实例: <!DOCTYPE HTML> <html> <head> <meta charset=" utf-8"> <title>javascript便利表格</title> <