android - 一个 ScrollView 只能有一个 child

标签 android

我是 android 编程的新手,我对“ ScrollView 只能有一个 child ”有疑问,我的脚本有什么问题? 我想知道你是否必须服用 ScroolView ?或者我该如何解决这个问题?任何人都可以正确编辑脚本吗?

<?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="-1"
 android:layout_height="-1">
<LinearLayout
 android:orientation="1"
 android:layout_width="-1"
 android:layout_height="-1">

<LinearLayout
 android:orientation="1"
 android:layout_width="-1"
 android:layout_height="-1"
 android:layout_marginLeft="12800"
 android:layout_marginTop="2560">

<TextView
 android:textColor="-1"
 android:layout_width="-2"
 android:layout_height="-2"
 android:text="2131034150"/>

<Spinner
 android:id="2131165208"
 android:layout_width="94720"
 android:layout_height="-2"
 android:drawSelectorOnTop="-1"
 android:prompt="2131034149"/>



<TextView
 android:textColor="-1"
 android:layout_width="-2"
 android:layout_height="-2"
 android:text="2131034143"/>
<EditText
 android:id="2131165202"
 android:layout_width="-2"
 android:layout_height="-2"
 android:maxLines="1"
 android:width="94721"
 android:maxLength="50"/>
<TextView
 android:textColor="-1"
 android:layout_width="-2"
 android:layout_height="-2"
 android:text="2131034144"/>
<EditText
 android:id="2131165203"
 android:layout_width="-2"
 android:layout_height="-2"
 android:maxLines="1"
 android:width="94721"
 android:password="-1"
 android:maxLength="30"/>
 </LinearLayout>
<LinearLayout
 android:layout_gravity="3"
 android:orientation="0"
 android:paddingLeft="58881"
 android:paddingBottom="5121"
 android:layout_width="-2"
 android:layout_height="-2">
 <Button
 android:id="2131165204"
 android:layout_width="-2"
 android:layout_height="-2"
 android:text="2131034145"
 android:width="35841"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

最佳答案

错误是不言自明的。

一个 ScrollView 只能有一个直接 subview 。

因此制作一个容器布局,其中包含您所有的 child 。并将该容器布局放置在 ScrollView 中。

示例层次结构:

<ScrollView>
    <LinearLayout>  <!-- new container layout-->

        <!-- all your children layouts, views -->
    </LinearLayou>
</ScrollView>

关于android - 一个 ScrollView 只能有一个 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25974350/

相关文章:

android - 以编程方式切换复选框

Android:从 .java 设置 EditText 的默认提示颜色

android - 如何通过 adb 在连接的设备之一上安装 apk?

java - 使用 Google Maps Places API 从一组位置中查找离当前位置最近的位置

android - 动画透明GIF图像

android - 如何将 XML 转换为 Android 二进制 XML

android - 从横向切换到纵向会产生 NullPointerException

android - 用于任务管理的 android 和 web 应用程序(可能是 iOS)的裸 JSON、nosql db 或 sqlite

android - Edittext 输入类型常量值不匹配

android - 用于 Android NDK ECLIPSE 插件的 NVIDIA 调试管理器