Thomas Thomas - 24 days ago 6
Android Question

Excel-looking behaviour in an Android UI

I am trying to create an Android View, but im struggling. So hoping someone can help:

Basically it's a table, but the leftmost column should not be scrollable, and the rest should be scrollable. Just like Excel. the leftmost column (with all the increasing numbers) never go away, even if you scroll to column XX.

Any clues on how to implement this? The reason is that the leftmost columns will be a list of keys, and the rest of the columns will be values.

Answer

A scetch of what I was trying to do

Using my leet skills in Ms Paint I drew this thing. So the idea is that when you swipe up and down... everything will scroll... But when you swipe left to right only the table to the right will move. The left will be static.

I will add the source here as well:

<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>

The key was to use the HorizontalScrollView instead of the ordinary ScrollView