如果我有一个 ViewFlipper 并且 ScrollView 只包含一个子项,我该怎么办?

发布于 2024-10-04 06:17:20 字数 668 浏览 0 评论 0原文

我实际上只需要将我的 ScrollView 包裹在我的 ViewFlipper 中的 3 个 LinearLayout 中的 1 个,但我尝试将它包裹在我的第三个中孩子,它给了我一个错误,即 ScrollView 只能承载一个直接孩子。

有什么解决方法吗?

<ViewFlipper>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <ScrollView android:id="@+id/ScrollView01"
             android:layout_width="fill_parent"
             android:layout_height="110dp">

      <!--- Stuff --->

        </ScrollView>
    </LinearLayout>
</ViewFlipper>

I really only need my ScrollView wrapped around 1 of the 3 LinearLayouts I have in my ViewFlipper, but I try to wrap it around my 3rd child and it gives me the error that ScrollView can only host one direct child.

Any workarounds?

<ViewFlipper>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <ScrollView android:id="@+id/ScrollView01"
             android:layout_width="fill_parent"
             android:layout_height="110dp">

      <!--- Stuff --->

        </ScrollView>
    </LinearLayout>
</ViewFlipper>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情归归情 2024-10-11 06:17:20

当然可以 - 将 ScrollView 的一个子级设为 FrameLayoutLinearLayoutRelativeLayout 并将内容放入其中。

Sure - make the one child of your ScrollView a FrameLayout, LinearLayout or RelativeLayout and put the content in that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文