ScrollView

来源:互联网 发布:金融工程硕士就业 知乎 编辑:程序博客网 时间:2024/05/17 06:37

今天在开发的时候,出现了一个错误提示:

02-23 05:26:55.564: ERROR/AndroidRuntime(447): Caused by: java.lang.IllegalStateException: ScrollView can host only one direct child

经查文档发现这么一句话:

A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through.

于是把scrollView往前挪动一下即可


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

</LinearLayout>
</ScrollView>