Black Screen using ScrollView + RelativeLayout and a costum View (acting like a canvas)

谁说我不能喝 提交于 2019-12-25 09:45:08

问题


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:

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:

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>

回答1:


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



来源:https://stackoverflow.com/questions/8280051/black-screen-using-scrollview-relativelayout-and-a-costum-view-acting-like-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!