Venkatesan Ramdoss
Venkatesan Ramdoss

Reputation: 77

android Expandable List view slide up down animation for child view

I want to animate slide up slide down animation on expandable list view. when I click the group Item, It will expand the child view and collapse it.In the get Child view method I am populating the child views.

The following code to populate child views.

public View getChildView(int groupPosition, int childPosition, 
        boolean isLastChild, View convertView, ViewGroup parent) { 
    Log.i(TAG, "getChildView"); 
    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; 
} 

How can I solve my problem.please help... Thanks & Regards, Venkatesan.R

Upvotes: 2

Views: 4863

Answers (2)

idunnololz
idunnololz

Reputation: 8363

I recently just wrote an widget for doing exactly what you've asked for. I've released the source code here: Android ExpandableListView using animation

I may improve the implementation and add comments in the future, but the main idea will stay the same. Take a look at this post if you are interested in how it works: Android ExpandableListView using animation.

Upvotes: 1

A. Binzxxxxxx
A. Binzxxxxxx

Reputation: 2881

the ListView classes are made for performance for a great number of rows with just in time drawing while sliding. so animation is no goal of this kind of view and not that easy.
maybe something like android:animateLayoutChanges="true" could work.
you can also take a look here: link

Upvotes: 0

Related Questions