如何滚动表的布局在Android的水平和垂直布局、水平和、Android

2023-09-12 23:49:24 作者:遇见你,在最美的年华。

我在表格布局滚动完全糊涂了。我要实现表,水平和垂直滚动。我也看到了表的修复头的例子,但tablefixheader样品已经使用适配器设置数据,但我需要在表格布局中添加视图的方法。     我已经使用低于code,但它不能支持双向滚动

 <滚动型
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:滚动条=垂直>

        < Horizo​​ntalScrollView
            机器人:layout_width =match_parent
            机器人:layout_height =FILL_PARENT
            机器人:fadeScrollbars =假>

            < TableLayout
                机器人:ID =@ + ID / tableLayoutId
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT/>
        < / Horizo​​ntalScrollView>
    < /滚动型>
 

解决方案

这是我是如何实现它,并为我的作品:

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直>
 <滚动型
    机器人:ID =@ + ID /布局
    机器人:layout_height =match_parent
    机器人:滚动条=横|纵
    机器人:layout_width =match_parent
    机器人:layout_marginTop =5dip
    机器人:scrollbarStyle =outsideInset
    机器人:fillViewport =真正的>

    < Horizo​​ntalScrollView
        机器人:ID =@ + ID / horizo​​ntalView
        机器人:layout_height =WRAP_CONTENT
        机器人:滚动条=横|纵
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_marginTop =5dip>

        < TableLayout
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            机器人:ID =@ + ID / tlGridTable>
        < / TableLayout>
    < / Horizo​​ntalScrollView>
< /滚动型>
< / LinearLayout中>
 
android 核心组件 1 常用布局, adapter, handler, UI

看看这个code,看看这会有所帮助。

I am totally confused in table layout scroll. I have to implement table with horizontal and vertical scrolling. I have also saw table fix header example but tablefixheader sample have used adapter to set data but i require add-view method in table layout. I have used below code but it couldn't support both ways scrolling

      <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="vertical" >

        <HorizontalScrollView
            android:layout_width="match_parent"
            android:layout_height="fill_parent" 
            android:fadeScrollbars="false">

            <TableLayout
                android:id="@+id/tableLayoutId"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </HorizontalScrollView>
    </ScrollView>

解决方案

This is how I implemented it and works for me:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
 <ScrollView 
    android:id="@+id/layout" 
    android:layout_height="match_parent"         
    android:scrollbars="horizontal|vertical" 
    android:layout_width="match_parent"     
    android:layout_marginTop="5dip"     
    android:scrollbarStyle="outsideInset"
    android:fillViewport="true"> 

    <HorizontalScrollView 
        android:id="@+id/horizontalView" 
        android:layout_height="wrap_content"     
        android:scrollbars="horizontal|vertical" 
        android:layout_width="wrap_content"     
        android:layout_marginTop="5dip">

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/tlGridTable" >   
        </TableLayout>
    </HorizontalScrollView>
</ScrollView>
</LinearLayout>

Take a look at this code and see if this helps.