Open sebastian-ruiz opened 10 years ago
Yes, this is by design. I didnt know how to calculate a view height before displaying it.
If you have a solution please tell me! I tried a lot of stuff.
Maybe it'll be enough to remember the view height after the first animation?
I've seen other libraries using onPreDrawListener for this kind of calculation, maybe it is the way to treat this.
I'm managed to fix it. AbstractSlideExpandableListAdapter.java
public View getView(int position, View view, ViewGroup viewGroup) {
this.parent = viewGroup;
view = wrapped.getView(position, view, viewGroup);
final View finalView = view;
final ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
viewTreeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
finalView.getViewTreeObserver().removeOnPreDrawListener(this);
enableFor(finalView, position);
return true;
}
});
return view;
}
...
public void enableFor(View parent, int position) {
View more = getExpandToggleButton(parent);
View itemToolbar = getExpandableView(parent);
enableFor(more, itemToolbar, position);
}
On pressing the expandable handle, the expandable section jumps open without animation, and immediately afterwards it animates open.
I am using it as follows:
Any help would be greatly appreciated.