Pregunta

In view hierarchy:

  • ViewParent > ScrollView > LinearLayout

When dimensions change, ViewParent.onMeasure calls ScrollView.onMeasure witch calls LinearLayout.onMeasure only if ScrollView.width have changed, what seems normal because LinearLayout is only constrained by his parent width.

How to force LinearLayout.onMeasure, also if ScrollView.width not changed ?

¿Fue útil?

Solución

The solution

override ScrollView.onMeasure and add LinearLayout.forceLayout call:

@Override
protected void onMeasure(int wMS, int hMS) {
    if (getChildCount() > 0)
        getChildAt(0).forceLayout();
    super.onMeasure(wMS, hMS);
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top