【问题标题】:scrollview warning滚动视图警告
【发布时间】:2012-12-16 09:54:04
【问题描述】:

我对一个 Android 应用程序进行了一个简单的测试,以滚动查看 TextView,几乎没有错误,但我收到警告(此 ScrollView 布局或其 LinearLayout 父级无用),我不知道该怎么办。我希望我能得到你的帮助

here is the code:

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


<ScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_weight="1">
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hi"/>
</ScrollView>
</LinearLayout>

【问题讨论】:

    标签: android scroll scrollview


    【解决方案1】:

    花点时间考虑一下!如果线性布局占用了它可以占用的所有空间(比如 200x400 像素),那么滚动视图占用的空间与线性布局可以占用的一样多(200x400 像素),那么您的线性布局就变得毫无用处了! (理论上)

    尝试在滚动视图后添加更多内容——这可能会使您的警告消失

    【讨论】:

    • 或者去掉线性布局,让你的 ScrollView 作为父级,因为在上面的例子中,scrollView 只包含一个 TextView。对吗?
    • 是的,正确!我在想未来的线性布局可能会容纳更多视图。
    • 谢谢 Richard Lee,它的工作我在 ScrollView 之后添加了更多文本,它确实有效
    • 欢迎您,Shrikant 的建议也是正确的。确保我不会产生多余视图的最简单方法是想象我脑海中的视图。在这种情况下,滚动视图和线性布局 100% 的时间都是相同的,所以这是浪费 :) 很高兴我能提供帮助。祝你好运
    【解决方案2】:

    应该是最顶层的父级...从顶部蚂蚁中删除您的 LinearLayout 就完成了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-18
      • 1970-01-01
      • 2011-04-23
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-26
      相关资源
      最近更新 更多