Android 如果用户正在滚动其他水平滚动视图(垂直滚动视图的子视图),如何使垂直滚动视图的某些部分固定
我有两个ScrollView,水平ScrollView和垂直ScrollView,水平ScrollView作为垂直的子视图,我可以垂直和水平滚动 我需要一些垂直滚动视图的一部分是固定的,如果用户是水平滚动 当用户尝试垂直滚动时,他将滚动屏幕上的所有数据,但当他尝试水平滚动时,只应滚动屏幕的右侧部分,而不应滚动整个屏幕。我怎么做 我试图在垂直滚动视图中添加两个child,但似乎无法在滚动视图中添加多个child,因此我无法实现我想要的功能 我的XML中有类似的内容。使用此布局,我可以滚动x轴和y轴Android 如果用户正在滚动其他水平滚动视图(垂直滚动视图的子视图),如何使垂直滚动视图的某些部分固定,android,Android,我有两个ScrollView,水平ScrollView和垂直ScrollView,水平ScrollView作为垂直的子视图,我可以垂直和水平滚动 我需要一些垂直滚动视图的一部分是固定的,如果用户是水平滚动 当用户尝试垂直滚动时,他将滚动屏幕上的所有数据,但当他尝试水平滚动时,只应滚动屏幕的右侧部分,而不应滚动整个屏幕。我怎么做 我试图在垂直滚动视图中添加两个child,但似乎无法在滚动视图中添加多个child,因此我无法实现我想要的功能 我的XML中有类似的内容。使用此布局,我可以滚动x轴和y轴
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10px"
android:layout_gravity="right">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10px"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:nestedScrollingEnabled="false">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3" />
<Button
android:id="@+id/button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 4" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 5" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 6" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 7" />
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 8" />
<Button
android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 9" />
<Button
android:id="@+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 10" />
<Button
android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 11" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2" />
<Button
android:id="@+id/button21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3" />
<Button
android:id="@+id/button31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 4" />
<Button
android:id="@+id/button121"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 5" />
<Button
android:id="@+id/button41"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 6" />
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
将水平滚动视图设置为仅水平滚动的部分,而不是垂直滚动视图的全部内容。您不能向scrollView添加多个直接子级,因此请创建另一个布局,以承载垂直滚动部分和水平滚动部分scroll@Nanoc但是如果我这样做,我如何同步我的滚动视图呢?当我滚动垂直SV时,我需要滚动水平滚动视图的全部内容。但是如果我按照你说的方式来做,我将有两个完全不同的滚动视图,水平和垂直,彼此之间没有任何依赖关系。我说得对吗?它就像一个表,左边有固定的名称列。当您向右滚动时,表格左侧的名称仍将固定,但表格的其他列将更改。这就是我所需要的水平滚动视图仍然在滚动视图中,它应该仍然是垂直滚动的,你在说什么相互依赖???@Nanoc现在找到你了。它起作用了。并不像我想的那样精确,因为用这个解决方案很难做一些我想做的事情,但无论如何,这是我所问问题的正确解决方案。如果你写一个答案,我会把它标记为正确答案。嵌套滚动视图通常是一件不好的事情。