Android : When a view scales vertically up in my ScrollView, content below that view disappears

on Friday, March 20, 2015


I have a ScrollView that contains several RelativeLayouts and LinearLayouts as children, like this:



<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >

<RelativeLayout >

</RelativeLayout>

<LinearLayout >

</LinearLayout>

</ScrollView>


Now, when I click one of the layouts, I want it to expand and reveal more info. I have managed to do it by scaling the layout I want vertically by using a property animator eg.



relativeLayout.animate().scaleY(100).setDuration(duration).start();


At the same time, I use a property animator to move any views below the one I expand vertically so that there's enough space for the expanded layout. It works.


Unfortunately, the views that move somehow end up outside the viewport of the ScrollView, so I'm unable to scroll down and see the information in those views. Essentially, the vertical translation of those views renders their lower part unreachable, since the viewport does not expand too.


I have set the android:fillViewPort="true" in the ScrollView. I have also tried to do it programmatically (.setFillViewPort() on the ScrollView ) after the views have moved.


What's wrong? Why is it not working?


0 comments:

Post a Comment