我使用的是TableLayout。 我需要有此布局水平和垂直滚动。 默认情况下,我能够得到的观点,但水平滚动垂直滚动不工作。
我使用的Android SDK 1.5 R3。 我已经尝试过android:scrollbars="horizontal"
。
我已阅读一些论坛,在蛋糕更新,水平滚动是可能的。
我怎样才能让在两个方向上我的布局滚动?
我使用的是TableLayout。 我需要有此布局水平和垂直滚动。 默认情况下,我能够得到的观点,但水平滚动垂直滚动不工作。
我使用的Android SDK 1.5 R3。 我已经尝试过android:scrollbars="horizontal"
。
我已阅读一些论坛,在蛋糕更新,水平滚动是可能的。
我怎样才能让在两个方向上我的布局滚动?
我能找到一个简单的方法来实现这两个滚动的行为。
下面是它的XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scrollbars="vertical">
<HorizontalScrollView
android:layout_width="320px" android:layout_height="fill_parent">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linlay" android:layout_width="320px"
android:layout_height="fill_parent" android:stretchColumns="1"
android:background="#000000"/>
</HorizontalScrollView>
</ScrollView>
为时已晚,但我希望您的问题将很快与此代码来解决。 没有做更多的只是把你的代码在下面滚动视图。
<HorizontalScrollView
android:id="@+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
//xml code
</ScrollView>
</HorizontalScrollView>
在这篇文章中滚动型的垂直和水平的android他们谈论一个可能的解决方案,报价:
马特·克拉克已经建成基于Android源上的自定义视图,它似乎很好地工作: http://blog.gorges.us/2010/06/android-two-dimensional-scrollview
要注意的是在页面的类有一个错误计算视图的卧式宽度。 曼努埃尔Hilty一个修复程序中的注释:
解决方案:通过以下替换上线808的声明:
final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED);
用这个:
android:scrollbarAlwaysDrawHorizontalTrack="true"
例:
<Gallery android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarAlwaysDrawHorizontalTrack="true" />