Android 为什么水平滚动视图不工作?

Android 为什么水平滚动视图不工作?,android,scrollview,android-tablelayout,horizontalscrollview,Android,Scrollview,Android Tablelayout,Horizontalscrollview,我正在尝试使应用程序可以垂直滚动,在我的ScrollView中,我想让HorizontalView水平滚动我的一些TableLayout,ScrollView工作得很好,但水平方向不能滚动。我怎样才能解决这个问题?谢谢你的帮助 <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:fillViewport="true

我正在尝试使应用程序可以垂直滚动,在我的ScrollView中,我想让HorizontalView水平滚动我的一些TableLayout,ScrollView工作得很好,但水平方向不能滚动。我怎样才能解决这个问题?谢谢你的帮助

<HorizontalScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"        >
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"

                android:id="@+id/tablejdl"
                android:weightSum="7"
                android:layout_marginTop="20dp"
                >

                <TableRow
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:weightSum="7"
                    android:gravity="center_horizontal">

                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Barang"
                        android:layout_weight="2"
                        android:id="@+id/kodebar"
                        />
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Jumlah"
                        android:layout_weight="1"
                        android:id="@+id/jumlah"
                        />
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Sup1"
                        android:layout_weight="1"
                        android:id="@+id/namabar"/>
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Sup2"
                        android:layout_weight="1"
                        android:id="@+id/jumlahbar"/>

                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Sup3"
                        android:layout_weight="4"
                        android:id="@+id/stokbar"/>
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Total"
                        android:layout_weight="2"
                        android:id="@+id/jtotal"/>
                </TableRow>
            </TableLayout>

                <android.support.v7.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_below="@id/tablejdl"
                    android:id="@+id/recyclerpenawaran">
                </android.support.v7.widget.RecyclerView>

            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/recyclerpenawaran"
                android:id="@+id/tablejdl2"
                android:weightSum="7"
                android:layout_marginTop="15dp"
                >
                <TableRow
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:weightSum="7"
                    android:gravity="center_horizontal">

                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="2"
                        />
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"

                        />
                    <CheckBox
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:id="@+id/checksup1"/>
                    <CheckBox
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:id="@+id/checksup2"/>

                    <CheckBox
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"

                        android:layout_weight="1"
                        android:id="@+id/checksup3"/>
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Total"
                        android:layout_weight="1"
                        android:id="@+id/total"/>
                </TableRow>
            </TableLayout>
        </RelativeLayout>
    </LinearLayout>
</HorizontalScrollView>

为此,您可以使用NestedScrollview:-

 <android.support.v4.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent">
 <HorizontalScrollView
                 android:layout_width="wrap_content"
                android:layout_height="match_parent">
                 ...... 
 </HorizontalScrollView>
 </android.support.v4.widget.NestedScrollView>

...... 

因为您的水平滚动视图位于另一个滚动条中,该滚动条也具有相同的垂直滚动功能。禁用父垂直滚动应该可以。谢谢你的回答,但我也想在我的应用程序中垂直滚动@K.Sopeaktry仅使用recyclerview,您不需要horizontalscrollview视图组。RecyclerView有更多更新的方法,可以很容易地实现。因此,您可以在滚动子滚动视图时禁用父滚动视图。让我们看看这些答案可能会有所帮助。您需要在这两个方面进行更改,在代码更改中:-scrool=(NestedScrollView)findViewById(R.id.vertical);
 <android.support.v4.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent">
 <HorizontalScrollView
                 android:layout_width="wrap_content"
                android:layout_height="match_parent">
                 ...... 
 </HorizontalScrollView>
 </android.support.v4.widget.NestedScrollView>