【发布时间】:2020-05-13 12:14:10
【问题描述】:
当您可以冻结工作表的顶部窗格时,我正在尝试在 Excel 中实现类似的功能。我的标题在 HorizontalScrollView 中有一个 TableLayout。
对于我的内容,它是 ScrollView 内的 HorizontalScrollView 内的 TableLayout。我快接近了,但无法弄清楚为什么表格主体从我的视野中部开始。
实际的标题和行以编程方式加载“”。如您所见,行从屏幕的中间开始,它们滚动到实际行数之外。
我现在也遇到了 100 次修订前的水平滚动问题。
主要 XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="390dp"
android:layout_height="match_parent"
android:background="@drawable/bordered_stuff"
android:orientation="vertical">
<HorizontalScrollView
android:id="@+id/window_guild_listtab_header_scroller_horizontal"
android:layout_width="811dp"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_marginBottom="1dp"
android:scrollbars="none" >
<TableLayout
android:id="@+id/window_guild_listtab_table_header"
android:layout_width="811dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="2dp"
android:layout_marginRight="2dp">
<!--Data loaded here programatically-->
</TableLayout>
</HorizontalScrollView>
<ScrollView
android:id="@+id/window_guild_listtab_table_scroller"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_marginBottom="1dp"
android:fadeScrollbars="false"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarSize="3dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbarThumbVertical="@color/THEME_LIGHT_TEXT">
<HorizontalScrollView
android:id="@+id/window_guild_listtab_table_scroller_horizontal"
android:layout_width="811dp"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_marginBottom="1dp"
android:fadeScrollbars="false"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarSize="3dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbarThumbHorizontal="@color/THEME_LIGHT_TEXT">
<TableLayout
android:id="@+id/window_guild_listtab_table"
android:layout_width="811dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp">
<!--Data loaded here programatically-->
</TableLayout>
</HorizontalScrollView>
</ScrollView>
</LinearLayout>
下面是如何在不发布代码墙的情况下对行进行膨胀:
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/table_border"
android:divider="@color/THEME_LIGHT_TEXT"
android:showDividers="middle">
<ImageView
android:id="@+id/game_guild_list_row_flag_left_imageview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="1dp"
android:layout_weight="0.121"
android:gravity="center"
android:background="@drawable/bordered_stuff" />
<com.kisnardonline.helpers.FontTextView
android:id="@+id/game_guild_list_row_tag_value"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="1dp"
android:layout_weight="0.055"
android:gravity="center"
android:text=""
android:textColor="@color/THEME_LIGHT_TEXT"
android:textSize="13sp" />
【问题讨论】:
标签: android layout scrollview tablelayout horizontalscrollview