简体   繁体   English

animation 与更改活动的布局

[英]animation on layout with change activity

在此处输入图像描述

What I want, when I click on the login button of the first activity the yellow part slides down and the next activity opens.我想要的是,当我单击第一个活动的登录按钮时,黄色部分会向下滑动并打开下一个活动。 when I click on the signup button of the second screen(login screen) the yellow part of the second screen slides up and the first activity (sign up Activity)opens.当我点击第二个屏幕(登录屏幕)的注册按钮时,第二个屏幕的黄色部分向上滑动,第一个活动(注册活动)打开。 I have used slide-down animation on the linear layout on the first screen it works but not working smoothly.我在第一个屏幕上的线性布局上使用了向下滑动的 animation,它可以工作但不能顺利工作。 Any help??有什么帮助吗??

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_signup);
        mSignUpButton = findViewById(R.id.btnSigUp);
        linearLayout=findViewById(R.id.linearLayout1);
        mGotoLoginActivityButton=findViewById(R.id.btnLoginSignUpActivity);
        slideDown= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_down);

      
//listener for Login button
        mGotoLoginActivityButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                //setValidation();

                Intent intent = new Intent(SignupActivity.this, LoginActivity.class);
                startActivity(intent);
                linearLayout.startAnimation(slideDown);

            }
        });
    }

you shouldn't use two separated Activities for this purpose, use one and login and create account views should be packed into Fragment s.您不应该为此使用两个单独的活动,使用一个并登录和创建帐户视图应该打包到Fragment中。 this way will be way easier to animate between two views/fragments in on Activity , but if you really must use Activity then use Transitions (probably with shared elements), not animations, as these are working in one Activity during its runtime when visible (and you are currently running new Activity , which cover old one)这种方式将更容易在Activity中的两个视图/片段之间制作动画,但是如果您真的必须使用Activity ,则使用过渡(可能与共享元素),而不是动画,因为它们在一个Activity运行时可见(并且您当前正在运行新的Activity ,它涵盖了旧的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM