使用 ScrollView 黑屏 + relativeLayout 和服装视图(就像画布一样)
我正在尝试开发带有输入和输出的块表示。 主要思想是:
- 用户可以添加输出/输入
- 用户可以编辑添加的输出/输入
所以我们有这样的内容:
我设法构建了一个动态画布,当用户按下其中一个按钮时(绘制区域会增大),该画布会发生变化。
当画布大于屏幕高度时,问题就开始了。结果是这样的:
请注意,我有一个滚动视图。然而,滚动视图似乎将所有内容都变成了黑色。我的 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:
- A user can add outputs/inputs
- 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到过与您的问题类似的问题,我通过使用
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 usingandroid: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