Skip to content Skip to sidebar Skip to footer

Android Radio Button Animation

Hello guys I would like to ask a question related to custom radio button. I just designed the radio button with custom background and flip animation. So that when I click radio but

Solution 1:

by code, you can do something like this:

Animation anim = AnimationUtils.loadAnimation(this, R.anim./*YOUR ANIMATION*/);

anim.setAnimationListener(new Animation.AnimationListener(){
        @Override
        public void onAnimationStart(Animation arg0) {
        }           
        @Override
        public void onAnimationRepeat(Animation arg0) {
        }           
        @Override
        public void onAnimationEnd(Animation arg0) {
            if(ButtonName.isChecked()){
               ButtonName.setImageResource(R.drawable.ImageChecked);
            }else{
               ButtonName.setImageResource(R.drawable.ImageUnchecked);
            }
        }
    });

    ButtonName.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                ButtonName.startAnimation(anim);
            }
        });

Post a Comment for "Android Radio Button Animation"