1

BEFORE YOU SAY "Google says not to do this" PLEASE READ ALL OF MY QUESTION!!

The layout:

ScrollView -> RelativeLayout -> ScrollView -> RelativeLayout

The first ScrollView is necessary because form entries pull up the soft keyboard on some phones which hides the rest of the content. Having a ScrollView as the outer most container allows a user to scroll with the soft keyboard present.

The second ScrollView lower on the hierarchy is a ListView which is still scrollable.

I completely understand why devs are discouraged to have a ScrollView within another ScrollView. I need to figure out a way to get the two to work together. I tried disabling the outermost ScrollView when the inner most ScrollView get's a touch, but that didn't help.

Is there a way to get around this to where both will work (not at the same time of course)? I wouldn't even mind disabling the outermost ScrollView until the content page is changed again. There has to be a way..

Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
  • "The second ScrollView lower on the hierarchy is a ListView which is still scrollable." -- `ScrollView` != `ListView`. "I need to figure out a way to get the two to work together" -- or, you could replace the `ListView` with a `Spinner`. – CommonsWare Sep 20 '12 at 16:45
  • @CommonsWare the `Spinner` idea would work great, but unfortunately the list is of 20 or so articles with title, date, and teaser so I need a way to show it all with a custom layout :( – Jacksonkr Sep 20 '12 at 16:48

3 Answers3

4

Step #1: Remove the ScrollView.

Step #2: Make the first RelativeLayout be a header in your ListView via addHeaderView().

Step #3: Make the second RelativeLayout be a footer in your ListView via addFooterView().

The net effect is that the whole thing will be scrollable, without nested scrollable items.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

It will only work when you set the android:layout_height to a fixed value for your second ScrollView. The best way is to set a size depending on device, for that it would be better to create layout for each supported screen size ( value on dp like 150 dp). you shoud create separate layout: layout-small, layout-normal, layout-large .... see this link for optimization of the fixed size: http://developer.android.com/guide/practices/screens_support.html

Anis BEN NSIR
  • 2,555
  • 20
  • 29
0

The answer is to programmatically intercept the touch events form the outer most scrollview. I am using a class that I found in another SOF about Disabling a ScrollView Programattically.

Community
  • 1
  • 1
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284