垂直和水平滚动

时间:2010-10-26 17:27:56

标签: android scroll

我猜,我有一个很常见的问题。

我有Activity,在里面我需要三个屏幕。问题是,它们可以/应该以两种方式滚动(水平和垂直)。由于通常不鼓励使用普通的ScrollView嵌入HorizontalScrollView,并且通常会导致比解决更多的问题,是否有其他方法可以实现这一点,而无需编写自己的SurfaceView类并手动处理滚动?

到目前为止我尝试的是: 将HorizontalScrollViewScrollView相互嵌入。它运作不佳。虽然水平滚动几乎完美地工作(几乎因为我甚至可以在开始滚动之前看到第二个屏幕的一部分),但垂直根本不起作用(如预期的那样)并且部分覆盖屏幕。

我无法将其拆分为三个不同的活动,因为代码需要在所有3个页面中更改/更新视图。

<com.tseng.widget.TalentLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/TalentLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
>
    ... many dozen of other views here ...
</com.tseng.widget.TaletLayout>

这基本上是三个水平页面中每一个的布局。

实施此方法的最佳方法是什么?如果除了编写我自己的滚动功能之外没有其他解决方案,我可以看一下好的教程或代码吗?

1 个答案:

答案 0 :(得分:1)

据我所知,无法创建一个水平和垂直同时滚动的滚动视图。至少不那么容易。但是,您可以使用合并,但滚动仅限于水平或垂直...

这样的事情:

<?xml version="1.0" encoding="utf-8"?>
<merge 
    android:id="@+id/merge"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ScrollView android:id="@+id/ScrollView01" 

        <HorizontalScrollView 
        xmlns:android="http://schemas.android.com/apk/res/android"

            <TextView android:id="@+id/Text" 
            </TextView>

        </HorizontalScrollView>

    </ScrollView>
</merge>
相关问题