问题描述
我使用的是ViewSwitcher这让我轻松地来回翻转两个不同列表头之间,内置的动画。
I'm using a ViewSwitcher that lets me easily flip back and forth between two different List Headers with Animations built in.
然而,问题是这两种观点都大大不同高度的,看来,该ViewSwitcher与 layout_height =WRAP_CONTENT
,测量儿童和需要的更大的这两个高度作为它自己。这导致了大量的正下方的较小视图不需要的空白空间时,它被示出。
However, the problem is the two views are of greatly varying height and it appears that the ViewSwitcher with layout_height="wrap_content"
, measures both children and takes the greater of the two heights as its own. This results in a large amount of unwanted blank space immediately below the smaller view when it is showing.
我明白为什么需要这样ViewSwitcher行为,但它不希望我的应用程序的行为。
I understand why this is desired ViewSwitcher behavior, but it is NOT desired My App behavior.
例:
说视图A是50dp高大查看B是100dp高,都被添加作为孩子的ViewSwitcher。该ViewSwitcher总是100dp高的甚至有景参观。
Example:
Say View A is 50dp tall and View B is 100dp tall and both are added as children to the ViewSwitcher. The ViewSwitcher always is 100dp tall even with View A showing.
我要的是能A和B之间进行切换,有ViewSwitcher缩小或增加当前显示的任何观点,以适应。我怎样才能做到这一点?
推荐答案
设置在 measureAllChildren
属性 ViewSwitcher
以假
。
<ViewSwitcher
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:measureAllChildren="false">
有关详细信息请参阅documentation.
这篇关于如何获得ViewSwitcher包只对目前显示的视图的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!