Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
android expandableListView animate slide up?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
elvinlee  
View profile  
 More options May 7 2012, 10:59 pm
From: elvinlee <lxm...@gmail.com>
Date: Mon, 7 May 2012 19:59:50 -0700 (PDT)
Local: Mon, May 7 2012 10:59 pm
Subject: android expandableListView animate slide up?
I want to animate slide down and slide up on expandablelistview when I
click the groupItem.Then I have finish the slide down.
public class ExpandAnimation extends Animation {
private static final String TAG = "ExpandAnimation";
private View mAnimatedView;
private LayoutParams mViewLayoutParams;
private int mMarginStart, mMarginEnd;
private boolean mIsVisibleAfter = false;
private boolean mWasEndedAlready = false;

/**
 * Initialize the animation
 * @param view The layout we want to animate
 * @param duration The duration of the animation, in ms
 */
public ExpandAnimation(View view, int duration) {

    setDuration(duration);
    mAnimatedView = view;
    mViewLayoutParams = (LayoutParams) view.getLayoutParams();
    // if the bottom margin is 0,
    // then after the animation will end it'll be negative, and
invisible.
    mIsVisibleAfter = (mViewLayoutParams.bottomMargin == 0);

    mMarginStart = mViewLayoutParams.bottomMargin;
    Log.i(TAG, "mMarginStart:>>>>>>>"+mMarginStart);
    mMarginEnd = (mMarginStart == 0 ? (0- view.getHeight()) : 0);
    Log.i(TAG, "mMarginEnd:>>>>>>>"+mMarginEnd);

    view.setVisibility(View.VISIBLE);

}

@Override
protected void applyTransformation(float interpolatedTime,
Transformation t) {
    super.applyTransformation(interpolatedTime, t);
    Log.i(TAG, "applyTransformation-->"+interpolatedTime);
    if (interpolatedTime < 1.0f) {

        // Calculating the new bottom margin, and setting it
        mViewLayoutParams.bottomMargin = mMarginStart
                + (int) ((mMarginEnd - mMarginStart) *
interpolatedTime);

        // Invalidating the layout, making us seeing the changes we
made
        mAnimatedView.requestLayout();

    // Making sure we didn't run the ending before (it happens!)
    } else if (!mWasEndedAlready) {
        mViewLayoutParams.bottomMargin = mMarginEnd;
        mAnimatedView.requestLayout();

        if (mIsVisibleAfter) {
            mAnimatedView.setVisibility(View.GONE);

        }
        mWasEndedAlready = true;
    }

}
}

public View getChildView(int groupPosition, int childPosition,
        boolean isLastChild, View convertView, ViewGroup parent) {
    Log.i(TAG, "getChildView");
    @SuppressWarnings("unchecked")
    String text = ((Map<String, String>) getChild(groupPosition,
            childPosition)).get("child");
    if (convertView == null) {
        LayoutInflater layoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        convertView = layoutInflater.inflate(R.layout.child, null);

    }
    View toolbar = convertView.findViewById(R.id.toolbar);
    setAnimationView(toolbar);
    ((LinearLayout.LayoutParams)
toolbar.getLayoutParams()).bottomMargin = -75;
    toolbar.setVisibility(View.GONE);
    ExpandAnimation expandAni = new ExpandAnimation(toolbar, 1000);
    toolbar.startAnimation(expandAni);
    TextView tv = (TextView) convertView.findViewById(R.id.childTo);
    tv.setText(text);

    return convertView;

}

But when I click the groupItem to collapse the group,it doesn't call
the getChildView() method.So how can I to call the getChildView() and
let it slide up? Thanks.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »