Android 使用ScrollView&;TableLayout中的水平滚动视图

Android 使用ScrollView&;TableLayout中的水平滚动视图,android,android-layout,Android,Android Layout,如何设置垂直和水平方向的ScrollView?我尝试了下面的代码,但没有成功 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbarFadeDuration="1000"

如何设置垂直和水平方向的
ScrollView
?我尝试了下面的代码,但没有成功

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbarFadeDuration="1000"
        android:scrollbarSize="12dip"
        android:background="@color/red" >

        <HorizontalScrollView android:id="@+id/horizontalScrollView1" android:layout_width="wrap_content" android:layout_height="wrap_content">
            <TableLayout android:layout_width="match_parent"  android:layout_marginTop="10dp" android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:stretchColumns="1" android:collapseColumns="2">

            </TableLayout>
        </HorizontalScrollView>
</ScrollView>

这是我的全部代码:

线性布局(@+id/linearLayout3)方向是水平的,使其垂直,以便内容显示在下面。我认为目前,您的列表分隔符和列表项在屏幕上水平添加,而不是垂直添加。

试试看

设置android:scrollbarFadeDuration=“0”

ScrollView1.SetScrollBarFadinEnabled(假)

android:scrollbarFadeDuration=“0”和

android:scrollbarAlwaysDrawVerticalTrack=“true”表示垂直

android:scrollbarAlwaysDrawHorizontalTrack=“true”表示水平

还有一件事

记住,ScrollView只能有一个子控件,因此我们可以将容器(线性、相对、表布局)作为ScrollView的子控件,并将所有控件放在这个子控件中

供参考:


尝试将
滚动视图的高度更改为
“填充父项”

如果是要水平移动的行,那么我建议将布局设计为

Scrollview作为父级,table layout作为其唯一的子级,然后将表格行添加到表格布局中,将horizontalscrollview放在每个表格行中。这样可以垂直移动表格,水平移动表格中的行


希望这有帮助。

根据您的建议,它会在每行显示水平滚动条吗?是吗?是的,如果不需要,您可以随时禁用滚动条。
       OR 
       OR