0

我的 android 应用程序中有以下 xml:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp" 
         android:background="@drawable/msngr"
>
 <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

     <ImageView
         android:id="@+id/imageView1"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:src="@drawable/logo" />
     </LinearLayout>
</ScrollView>

这段代码很好,但我无法在其中添加任何其他组件,如 TextView、Edittext。

我没有得到任何自动建议并在红线中查看:

<linearlayout> has no known child tags

我如何在线性布局中使用组件?

请帮助我。

4

1 回答 1

4

这是因为在 ScrollView 中您只能添加一个子视图...它不能在其中添加任何其他视图...因为 ScrollView 仅托管一个子视图...

还从线性布局中删除空间

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

 <ImageView
     android:id="@+id/imageView1"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:src="@drawable/logo"/>
 </LinearLayout>

因为空间不允许......

and if you want to add child view then add it to only LInear Layout
于 2013-09-10T10:08:03.197 回答