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);
}
Question
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 ?
Solution
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);
}