使用 ScrollView 黑屏 + relativeLayout 和服装视图(就像画布一样)

发布于 2024-12-18 07:23:13 字数 1053 浏览 5 评论 0原文

我正在尝试开发带有输入和输出的块表示。 主要思想是:

  1. 用户可以添加输出/输入
  2. 用户可以编辑添加的输出/输入

所以我们有这样的内容:

在此处输入图像描述

我设法构建了一个动态画布,当用户按下其中一个按钮时(绘制区域会增大),该画布会发生变化。

当画布大于屏幕高度时,问题就开始了。结果是这样的:

在此处输入图像描述

请注意,我有一个滚动视图。然而,滚动视图似乎将所有内容都变成了黑色。我的 xml 文件是这样的:

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true">
    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <pt.mypackage.BlockCanvas
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <EditText 
            ... />

        <Button
            ... />    

        <Button
            ... />    

    </RelativeLayout>
</ScrollView>

I am trying to develop a block representation with inputs and outputs.
The main ideia is:

  1. A user can add outputs/inputs
  2. A user can edit the ouputs/inputs added

So we have something like this:

enter image description here

I managed to build a dynamic canvas that changes when the user presses one of the buttons (the painted area grows).

The problem starts when the canvas is bigger than screen height. The result is something like this:

enter image description here

Notice that I have a scroll view. However it seems that scrollview puts everything in black. My xml file is something like this:

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true">
    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <pt.mypackage.BlockCanvas
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <EditText 
            ... />

        <Button
            ... />    

        <Button
            ... />    

    </RelativeLayout>
</ScrollView>

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

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

发布评论

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

评论(1

命比纸薄 2024-12-25 07:23:14

我遇到过与您的问题类似的问题,我通过使用 RelativeLayout 包装滚动视图并使用 android:layout_allignParentTop="true" 解决了它。如果不起作用,请尝试添加空视图(没有高度,只有宽度),它将作为您的 ScrollView 将放置在下面的锚点。我希望这有意义并且有效

I've experience something similar to your problem, I solved it by wrapping up the scroll view with RelativeLayout and using android:layout_allignParentTop="true". If doesnt work try adding empty view(no height just width) that will work as anchor to which your ScrollView will be placed below. I hope this makes sense and works

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