我正在尝试创建一个 Android View ,但我很吃力。所以希望有人能帮忙:
基本上它是一个表格,但最左边的列不应该是可滚动的,其余的应该是可滚动的。就像Excel一样。最左边的列(所有递增的数字)永远不会消失,即使您滚动到第 XX 列也是如此。
关于如何实现这个的任何线索?原因是最左边的列将是键列表,其余列将是值。
最佳答案
我利用我在 Ms Paint 中的 leet 技能画了这个东西。所以这个想法是,当你上下滑动时……一切都会滚动……但是当你从左向右滑动时,只有右边的表格会移动。左侧将是静态的。
我也会在这里添加源:
<LinearLayout
android:id="@+id/widget60"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:scrollbars="vertical"
>
<TableLayout
android:id="@+id/schedule_stops"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
>
</TableLayout>
<HorizontalScrollView
android:id="@+id/widget69"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/schedule_stops"
>
<TableLayout
android:id="@+id/schedule_times"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
>
</TableLayout>
</HorizontalScrollView>
</LinearLayout>
关键是使用 HorizontalScrollView 而不是普通的 ScrollView
关于android - Android UI 中类似 Excel 的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8229452/