android-我的滚动视图出错

android-我的滚动视图出错,android,scrollview,Android,Scrollview,我想制作一个滚动视图,其中包括一个线性布局: <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="#000000" > <LinearLayout android:id="@+id/ma

我想制作一个
滚动视图
,其中包括一个
线性布局

    <ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:background="#000000" >

    <LinearLayout
        android:id="@+id/mainHolder"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:orientation="horizontal" />
    </ScrollView>


现在,当我将子对象添加到mainHolder时,我无法滚动。怎么了?

您正在将子对象添加到线性布局中,该布局在方向上是水平的 所以它水平地包装内容

将线性布局的方向更改为垂直,或尝试


您正在将子对象添加到方向为水平的线性布局中 所以它水平地包装内容

将线性布局的方向更改为垂直,或尝试



ScrollView仅支持垂直滚动。对于水平滚动,请使用。

滚动视图仅支持垂直滚动。对于水平滚动,使用。

在垂直滚动视图中添加水平线性布局是可疑的

对于水平滚动,请使用


而且,
wrap_内容
size在滚动方向上没有意义。如果它真的被包装成内容大小,就不需要滚动。

在垂直滚动视图中添加水平线性布局是可疑的

对于水平滚动,请使用

而且,
wrap_内容
size在滚动方向上没有意义。如果它真的被包装成内容大小,就不需要滚动。

试试这个



试试这个




但是我想要水平的orientation@Soheil因此,在水平方向的线性布局中添加线性布局垂直方向,但我想要水平方向orientation@Soheil所以在水平方向的线性布局中添加线性布局垂直方向将滚动视图放入线性布局中?!!!!!!为什么?将ScrollView的方向更改为垂直,则无法滚动,因为滚动视图中没有某些项目。将ScrollView置于LinearLayout中?!!!!!!为什么?将ScrollView的方向更改为垂直,则无法滚动,因为滚动视图中没有某些项目。如果此答案解决了您的问题,您应该接受它@如果这个答案解决了你的问题,你应该接受它@SoheilThis仅向视图层次结构添加一个附加级别,而根本不改变OP的问题。这仅向视图层次结构添加一个附加级别,而根本不改变OP的问题。
<LinearLayout
        android:id="@+id/mainHolder"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:orientation="vertical" />
<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:background="#000000" >
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/mainHolder"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#000000"
            android:orientation="horizontal" />
    </LinearLayout>
</ScrollView>