I have a TableLayout which is in a ScrollView, so I get vertical scroll. But when the col开发者_Go百科umns exceed the screen with, I want the horizontal scroll also.
How can I do this? Please help.
Thanks, Farha
take a look at this, it may be what u want.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:src="@drawable/icon"/>
<ImageView android:src="@drawable/tube"/>
</TableRow>
<TableRow ....
</TableRow>
<TableRow ....
</TableRow>
</TableLayout>
</HorizontalScrollView>
</ScrollView>
I would have a go with:
android:scrollbars="horizontal"
in your xml definition of the view, however if you are using a scrollview, it does not support horizontal scrolling, so the bar won't display...
put attribute in scroll view tag.
android:scrollbars="horizontal"
horizontalscrollview http://developer.android.com/reference/android/widget/HorizontalScrollView.html was added in 1.5
Place the HorizontalScrollView inside the ScrollView as mentioned above. Here is a tutorial on how to do just that: http://androiddevblog.blogspot.com/2009/12/creating-two-dimensions-scroll-view.html
精彩评论