Sunday, 7 December 2014

Android vertical and horizontal scroll bar



I have a table layout that has many columns, so I need to scroll them horizontally. But for scrolling through the rows, I need to scroll it vertically. So I just put a HorizontalScrollView in a ScrollView, and this is working fine.


Now, my problem is: My vertical scroll bar is always visible when scrolling (and this is also what I want), but the horizontal scroll bar is only visible when I scrolled my vertical scroll bar to the bottom, because it is painted relative to the vertical scroll view. If I swap ScrollView and HorizontalScrollView, the horizontal scroll bar is always visible and the vertical scroll bar is not.


Can I make them both drawn at the bottom/at the right of my view?


My Code:



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/lastUpdate"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<ScrollView
android:id="@+id/scrollVertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="vertical" >

<HorizontalScrollView
android:id="@+id/scrollHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="horizontal" >

<RelativeLayout
android:id="@+id/scrollContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</HorizontalScrollView>
</ScrollView>

</RelativeLayout>

No comments:

Post a Comment