gpt4 book ai didi

android - 使用 ViewFlipper 动态调整布局大小

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:26:06 28 4
gpt4 key购买 nike

我有布局大小问题...

我有一个布局,它由一个 ViewFlipper、一个 LinearLayout(包含一个 MapView)和一个垂直行中的第二个 LinearLayout 组成。

<LinearLayout
android:width="match_parent"
android:height="match_parent" >

<ViewFlipper
android:width="match_parent"
android:height="wrap_content" >
// Top elements
</ViewFlipper>

<LinearLayout
android:width="match_parent"
android:height="match_parent" >
// MapView
</LinearLayout>

<LinearLayout
android:width="match_parent"
android:height="wrap_content" >
// Bottom elements
</LinearLayout>

</LinearLayout>

我看到的问题是,当我使用 showNext() 或 showPrevious() 更改 ViewFlipper 以显示较短的 View 时,中间的 LinearLayout 不会展开以填充空间。此外,当我更改为较短的 View 时,我会看到之前的 ViewFlipper View 留下的黑色/空白区域。

有没有一种灵活的方法来动态调整这些元素的大小,以便 MapView 布局将扩展以填充所有未被 ViewFlipper 和底部 LinearLayout 占用的空间?

最佳答案

尝试将 android:measureAllChildren="false" 添加到您的 ViewFlipper

<ViewFlipper
android:width="match_parent"
android:height="wrap_content"
android:measureAllChildren="false" >
<!-- Top elements -->
</ViewFlipper>

关于android - 使用 ViewFlipper 动态调整布局大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13756875/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com