首页 > 解决方案 > 我想在单击单选按钮时为该布局设置动画。但它不起作用

问题描述

我想在单击单选按钮时为该布局设置动画。但它不起作用

这是我的布局 1

单选按钮的状态更改侦听器

radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.radio_button_login){
                    Animation animation = AnimationUtils.loadAnimation(LoginActivity.this,R.anim.bottom_up);
                    signUpLayout.setAnimation(animation);
                    animation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {

                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            signUpLayout.setVisibility(View.INVISIBLE);
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });

                }else {
                    Log.e("TAG", "onCheckedChanged: "+checkedId +"  :  "+ R.id.radio_button_login );
                    signUpLayout.setVisibility(View.VISIBLE);

                }
            }
        });

但是动画只有在我点击布局中的 Edittext 时才开始

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="200">
<scale android:fromXScale="100%" android:toXScale="100%" android:fromYScale="100%" android:toYScale="0%"/>
</set>

这是我的动画资源

标签: javaandroidandroid-animation

解决方案


推荐阅读