我正在使用ScrollView在垂直LinearLayout上滚动。 LinearLayout根据用户输入调整自身大小。当调整大小时,我想重新定位滚动位置,以便查看LinearLayout的相同区域。除了滚动位于页面底部附近时,此工作正常。当发生这种情况时,我的svVerticalScroll.scrollTo(...)调用似乎被忽略(我可以根据调试来判断,在这种情况下,svVerticalScroll.getScrollY()在调用后保持不变)。我假设这被忽略,因为scrollTo(...)参数大于最大滚动范围,因为scrollView没有调整大小。那么......如何强制ScrollView调整大小?
float centerY = svVerticalScroll.getScrollY() + m_ScreenHeight / 2;
m_CurrentScale = m_CurrentScale * delta;
myLinearLayout.doResize(m_CurrentScale);
myLinearLayout.requestLayout();
svVerticalScroll.invalidate();
svVerticalScroll.requestLayout();
float newcenterY = centerY * delta;
svVerticalScroll.scrollTo(0, (int) (newcenterY - m_ScreenHeight / 2));