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 8421401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:08:27+00:00 2026-06-10T03:08:27+00:00

I know it’s to be something very simple, but i don’t see the problem.

  • 0

I know it’s to be something very simple, but i don’t see the problem.

I’ve a LinearLayout:

LinearLayout menuSlide = (LinearLayout) findViewById(R.id.menuSlide);
menuSlide.startAnimation(new ExpandAnimation(menuSlide, 0, (int) (screenWidth*0.7), 20));

And the ExpandAnimation class:

public class ExpandAnimation extends Animation implements Animation.AnimationListener{

    private View view;
    private static int ANIMATION_DURATION;
    private static final String LOG_CAT = "ExpandAnimation";
    private int lastWidth;
    private int fromWidth;
    private int toWidth;
    private static int STEP_SIZE=30;

    public ExpandAnimation(View v,int fromWidth, int toWidth, int duration){
        Log.v(LOG_CAT, "Entramos en el constructor del ExpandAnimation");
        this.view = v;
        ANIMATION_DURATION = 1;
        this.fromWidth = fromWidth;
        this.toWidth = toWidth;

        setDuration(ANIMATION_DURATION);
        setRepeatCount(20);
        setFillAfter(false);
        setInterpolator(new AccelerateInterpolator());
        setAnimationListener(this);
        startNow();
    }

    @Override
    public void onAnimationEnd(Animation animation) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onAnimationRepeat(Animation animation) {
        // TODO Auto-generated method stub
        Log.v(LOG_CAT, "Entra en el onAnimationRepeat");
        LayoutParams lyp = view.getLayoutParams();
        lyp.width = lastWidth += toWidth/20;
        view.setLayoutParams(lyp);

        Log.v(LOG_CAT,"El objeto: " + view.getId() + " tiene ahora de ancho: " + view.getWidth());
    }

    @Override
    public void onAnimationStart(Animation animation) {
        // TODO Auto-generated method stub
        Log.v(LOG_CAT, "Entra en el onAnimationStart");
        LayoutParams lyp = view.getLayoutParams();
        lyp.width = 0;
        view.setLayoutParams(lyp);
        lastWidth=0;
    }

}

Ok, the program reach to the constructor of ExpandAnimation but nothing else, onAnimationStart is never fired.

What am i doing wrong?

  • 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-06-10T03:08:29+00:00Added an answer on June 10, 2026 at 3:08 am

    I didn’t run your code, but in

    public ExpandAnimation(View v,int fromWidth, int toWidth, int duration){
            Log.v(LOG_CAT, "Entramos en el constructor del ExpandAnimation");
          1.  this.view = v;
          2.   ANIMATION_DURATION = 1;
          3. this.fromWidth = fromWidth;
          4.  this.toWidth = toWidth;
    
            setDuration(ANIMATION_DURATION);
            setRepeatCount(20);
            setFillAfter(false);
            setInterpolator(new AccelerateInterpolator());
            setAnimationListener(this);
            startNow();
        }
    

    You did not set duration to a variable value, you could do something like ANIMATION_DURATION = duration; also ANIMATION_DURATION is just 1 ms, even if animation, happens you wont be able to see it try changing it to 500 etc.
    In, 1, 2, 3, 4 change

    view = v;
    ANIMATION_DURATION = duration;
    fromWidth = this.fromWidth;
    toWidth = this.toWidth;
    

    EDIT: Animating via code is difficult, the easier way to do it is via an XML file, FIRSTLY create a folder name anim under res folder then create an xml file named scale.xml and do the following…

    <set xmlns:android="http://schemas.android.com/apk/res/android"
          android:interpolator="@android:anim/accelerate_interpolator">
       <scale
          android:fromXScale="1"
          android:toXScale="1"
          android:fromYScale="0.1"
          android:toYScale="1.0"
          android:duration="500"
          android:pivotX="50%"
          android:pivotY="50%"
          android:startOffset="100" />
    </set> 
    

    Then in your Activity simply call

    Animation a = AnimationUtils.loadAnimation(this, R.anim.scale);
    ((LinearLayout) findViewById(R.id.yourlayoutID)).startAnimation(a);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is a very simple question for you experts,but please forgive me.Im
I know that design patterns is generally something that's connected to OO programming, but
I know very little about Agile but I wonder if there is any difference
I know that there's something fishy about the malloc part, but I'm having trouble
I know this is a pretty basic question, but I don't know how to
Know this might be rather basic, but I been trying to figure out how
I know you can not set a key value dynamically, but what about the
I know that Phonegap has an event for back button, but it's only available
I know that this sort of question has been asked here before, but still
i know this is a stupid question but i d'ont know how to do

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.