使用滚动+的RelativeLayout和costum查看黑屏(像一个帆布) [英] Black Screen using ScrollView + RelativeLayout and a costum View (acting like a canvas)

查看:214
本文介绍了使用滚动+的RelativeLayout和costum查看黑屏(像一个帆布)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个块重presentation带有输入和输出。
主要是IDEIA:


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

  2. 的用户可以编辑。OUPUTS /添加输入

因此​​,我们有这样的事情:

我设法建立一个充满活力的帆布改变当用户presses按钮(绘制区域增长)之一。

当画布大于屏幕高度更大的问题开始。其结果是这样的:

请注意,我有一个滚动视图。然而,它似乎把滚动视图中的一切黑色。我的XML文件是这样的:

 <滚动型
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:fillViewport =真正的>
    < RelativeLayout的
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT>        < pt.mypackage.BlockCanvas
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT/>        <的EditText
            ... />        <按钮
            ... />        <按钮
            ... />    < / RelativeLayout的>
< /滚动型>


解决方案

我有类似你的问题的经验的东西,我解决它通过包裹起来滚动视图与 RelativeLayout的和使用的android:layout_allignParentTop =真正的。如果不工作尝试添加空视图(不只是高度宽度),将工作作为锚到您的滚动型将在下面放置。我希望这是有道理和作品

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>

解决方案

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

这篇关于使用滚动+的RelativeLayout和costum查看黑屏(像一个帆布)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆