如何让我的布局水平和垂直滚动?
问题描述:
我正在使用 TableLayout.我需要为此布局同时进行水平和垂直滚动.默认情况下,我可以在视图中进行垂直滚动,但水平滚动不起作用.
I am using a TableLayout. I need to have both horizontal and vertical scrolling for this layout. By default I am able to get vertical scrolling in the view but horizontal scrolling is not working.
我使用的是 Android SDK 1.5 r3.我已经尝试过 android:scrollbars="horizontal"
.
I am using Android SDK 1.5 r3. I have already tried android:scrollbars="horizontal"
.
我在一些论坛上看到,在纸杯蛋糕更新中,可以进行水平滚动.
I have read on some forums that in the cupcake update, horizontal scrolling is possible.
如何让我的布局在两个方向滚动?
How can I make my layout scroll in both directions?
答
我找到了一种简单的方法来实现这两种滚动行为.
I was able to find a simple way to achieve both scrolling behaviors.
这是它的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
android:id="@+id/linlay" android:layout_width="320px"
android:layout_height="fill_parent" android:stretchColumns="1"
android:background="#000000"/>
</HorizontalScrollView>
</ScrollView>