Currently, I have a layout which looks like this. It contains.
I accomplished this for my accordion component. I was facing the exact same issue, of expanding my accordion which required the 'destination' height, that is, the height that it would take after the expansion. This returns the correct height:
/***
* This function returns the actual height the layout. The getHeight() function returns the current height which might be zero if
* the layout's visibility is GONE
* @param layout
* @return
*/
public static int getFullHeight(ViewGroup layout) {
int specWidth = View.MeasureSpec.makeMeasureSpec(0 /* any */, View.MeasureSpec.UNSPECIFIED);
int specHeight = View.MeasureSpec.makeMeasureSpec(0 /* any */, View.MeasureSpec.UNSPECIFIED);
layout.measure(specWidth,specHeight);
int totalHeight = 0;//layout.getMeasuredHeight();
int initialVisibility = layout.getVisibility();
layout.setVisibility(View.VISIBLE);
int numberOfChildren = layout.getChildCount();
for(int i = 0;i
You can take a look at the accordion component and the animation on GitHub: Android Accordion View