Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6925653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:49:03+00:00 2026-05-27T10:49:03+00:00

I have an Android view that includes a RadioGroup with three RadioButtons. When one

  • 0

I have an Android view that includes a RadioGroup with three RadioButtons. When one of the RadioButtons is selected, the user also has to enter text into an EditText control. If either of the other two RadioButtons are selected, this extra information is not required.

I’m currently using the OnCheckedChangedListener for the RadioGroup to determine when a new RadioButton is checked, and hiding the EditText by setting its visibility to View.GONE. However this is a little jarring, and I’m wondering if there is a way that I could animate the transition at all. Is this possible, and if so, whats the key to getting started?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:49:03+00:00Added an answer on May 27, 2026 at 10:49 am

    I’ve come up with the following workable solution, which was based on code I found at http://tech.chitgoks.com/2011/10/29/android-animation-to-expand-collapse-view-its-children/

    In my activity:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.edit_account);
        companyGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
        {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId)
            {
                if (checkedId == R.id.companyRadio)
                    EDNUtils.expandCollapse(companyNameText, true, 500);
                else
                    EDNUtils.expandCollapse(companyNameText, false, 500);
            }
        });
    }
    

    Implementation from EDNUtils:

    public static Animation expandCollapse(final View v, final boolean expand) 
    {       
        return expandCollapse(v, expand, 1000);
    }
    
    public static Animation expandCollapse(final View v, final boolean expand, final int duration) 
    {
        int currentHeight = v.getLayoutParams().height;
        v.measure(MeasureSpec.makeMeasureSpec(((View)v.getParent()).getMeasuredWidth(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        final int initialHeight = v.getMeasuredHeight();
    
        if ((expand && currentHeight == initialHeight) || (!expand && currentHeight == 0))
            return null;
    
        if (expand) 
            v.getLayoutParams().height = 0;
        else 
            v.getLayoutParams().height = initialHeight;
        v.setVisibility(View.VISIBLE);
    
        Animation a = new Animation() 
        {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) 
            {
                int newHeight = 0;
                if (expand) 
                    newHeight = (int) (initialHeight * interpolatedTime);
                else 
                    newHeight = (int) (initialHeight * (1 - interpolatedTime));
                v.getLayoutParams().height = newHeight;            
                v.requestLayout();
    
                if (interpolatedTime == 1 && !expand)
                    v.setVisibility(View.GONE);
            }
    
            @Override
            public boolean willChangeBounds()  
            {
                return true;
            }
        };
        a.setDuration(duration);
        v.startAnimation(a);
        return a;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android ListView with rows that include one checkbox, and four text
I have two threads in an Android application, one is the view thread, and
I have an Android project that branched into three different applications, app-1 , app-2
I have a custom view that extends ViewGroup . It includes a ProgressBar and
I have an Android app with a ListActivity in the main view. The list
I have android.permission.READ_OWNER_DATA but I can't find any reliable code that would explain how
I have an Android activity that displays a list of log entries (using a
I' have a view that contains several textViews an ImageView and a Button .
I have an Android application that generates some HTML which is rendered locally, in
I have xml file and that create view and i pass that screen shot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.