【发布时间】:2015-05-03 23:09:21
【问题描述】:
我在 ScrollView 中有一个 LinearLayout。在某些时候,我折叠并展开 LinearLayout。之后,滚动视图确实滚动。有什么想法吗?
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="false">
<LinearLayout
android:id="@+id/detailsView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
>
........
</LinearLayout>
</ScrollView>
使用 ValueAnimator 在 LinearLayout 的 LayoutParams(高度)上完成展开和折叠。
更新:我认为重要的是它在动画展开/折叠后分解。直到它工作正常。
更新2:为了再次展开,我测量了预期的高度如下:
int expectedHeight = detailsView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
并动画扩张到那个高度。这测量到 2000+ 的高度,而不是预期的 800 左右。因此大小相等,并且滚动视图没有滚动,尽管它没有显示完整的层次结构。
作为快速修复,我在折叠之前保存当前高度,并将其用作展开时的目标高度。问题是,这可以自动完成而不节省脏高度吗?
【问题讨论】:
-
我觉得截图没什么用——只有两个视图,一个在另一个里面,不能通过截图显示动态。
标签: android scrollview android-animation