Insert scrollbar into tablelayout

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Insert scrollbar into tablelayout

Postby blackgin » Tue May 12, 2009 5:03 pm

I have a table layout and I want to add a scrollbar because it exceed the vertical resolution of the screen..
How can I do this? I tried to use <ScrollView> but the programs fails to start (it force closes)..
User avatar
blackgin
Developer
Developer
 
Posts: 33
Joined: Tue Apr 21, 2009 1:21 pm

Top

Postby nmc » Tue May 12, 2009 7:27 pm

ScrollView is the correct answer;

Excerpt from one of my layouts:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.         <ScrollView
  3.  
  4.                 android:id="@+id/widget28"
  5.  
  6.                 android:layout_width="fill_parent"
  7.  
  8.                 android:layout_height="fill_parent"
  9.  
  10.                 android:layout_below="@+id/Save"
  11.  
  12.                 xmlns:android="http://schemas.android.com/apk/res/android"
  13.  
  14.                 android:scrollbarAlwaysDrawVerticalTrack="true"
  15.  
  16.                 android:scrollbars="vertical"
  17.  
  18.                 android:scrollbarSize="12px"
  19.  
  20.                 android:scrollbarStyle="insideOverlay"
  21.  
  22.                 >
  23.  
  24.                 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  25.  
  26.                         android:id="@+id/table"
  27.  
  28.                         android:layout_width="fill_parent"
  29.  
  30.                         android:layout_height="wrap_content"
  31.  
  32.                         android:layout_below="@+id/Back"
  33.  
  34.                         android:stretchColumns="1" android:baselineAligned="true" android:fitsSystemWindows="true" android:clipChildren="true">
  35.  
  36. ...
  37.  
  38.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Maybe some of the attribs shown above arent neccessary, but except for the table-bug in android, for which i wasnt able to find a workaround yet, this works just fine.
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Postby blackgin » Wed May 13, 2009 12:51 pm

I added this:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.      <ScrollView
  2.  
  3.          android:id="@+id/widget28"
  4.  
  5.          android:layout_width="fill_parent"
  6.  
  7.          android:layout_height="fill_parent"
  8.  
  9.          android:scrollbarAlwaysDrawVerticalTrack="true"
  10.  
  11.          android:scrollbars="vertical"
  12.  
  13.          android:scrollbarSize="12px"
  14.  
  15.          android:scrollbarStyle="insideOverlay"
  16.  
  17.          >
  18.  
  19. ..............................
  20.  
  21. </ScrollView>
  22.  
  23.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


But it doesn't work.. It says: "IllegalStateException: ScrollView can host only a direct child"
User avatar
blackgin
Developer
Developer
 
Posts: 33
Joined: Tue Apr 21, 2009 1:21 pm

Postby nmc » Wed May 13, 2009 6:53 pm

The message says all: if you have more then the mentioned table-layout in your scrollview, then you have to group all childs into one container view.

Expample:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <scrollview>
  3.  
  4.   <tablelayout>
  5.  
  6.   </tablelayout>
  7.  
  8.   <button />
  9.  
  10. </scrollview>
  11.  
  12.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


fails; solution:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <scrollview>
  3.  
  4.   <linearlayout>
  5.  
  6.     <tablelayout>
  7.  
  8.     </tablelayout>
  9.  
  10.     <button />
  11.  
  12.   </linearlayout>
  13.  
  14. </scrollview>
  15.  
  16.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Postby blackgin » Wed May 13, 2009 6:58 pm

I already tried this solution, but it still didn't work..
User avatar
blackgin
Developer
Developer
 
Posts: 33
Joined: Tue Apr 21, 2009 1:21 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 6 guests