I have an array of views, seats in the cinema. I need to apply a set of animation (scale and translate) to them to make some kind of zoom. I apply animation to every view. Animation looks like this:
AnimationSet set = new AnimationSet(context, null);
float toXDelta = (place.getX() * 2) - place.getX();
float toYDelta = (place.getY() * 2) - place.getY();
Animation translate = new TranslateAnimation(0, toXDelta, 0, toYDelta);
translate.setDuration(4000);
translate.setFillAfter(true);
translate.setFillEnabled(true);
Animation scale = new ScaleAnimation(1, 5, 1, 5);
scale.setDuration(4000);
scale.setFillAfter(true);
scale.setFillEnabled(true);
set.addAnimation(translate);
set.addAnimation(scale);
set.setFillAfter(true);
set.setAnimationListener(new KaroAnimationListener(this));
animation = set;
So, my layout looks like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_width="fill_parent"
android:padding="10px">
<ScrollView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="0"
android:id="@+id/vertical_scroll"
android:fillViewport="true">
<HorizontalScrollView
android:layout_height="fill_parent"
android:fillViewport="true"
android:id="@+id/scroll_view"
android:layout_width="wrap_content">
<RelativeLayout android:id="@+id/scrollable_places"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</RelativeLayout>
</HorizontalScrollView>
</ScrollView>
<Button android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/reserve_places_button"
android:onClick="onReserveClick"
android:layout_below="@id/vertical_scroll"
android:layout_weight="1"
android:text="Bron!"/>
I put my views into RelativeLayout
with id scrollable_pla开发者_运维问答ces
. So, after the end of animation some of this views go out of bounds of the screen, but there is no scroll available.
I guess that i need to redefine the dimentions
of RelativeLayout or other, parent, layouts
, but i don't know how to do it manually.
Thanks!
You could try to post delay a scroll to this end of your ScrollView like this :
scrollView.postDelayed( new Runnable() {
@Override
public void run() {
scrollView.fullScroll( View.FOCUS_DOWN);
}
}, 4300);
So that it fits to start after the end of your animation or you could do this after you listened to the end of your animation with an AnimationListener and in this case you could use a smaller delay than 4300 ms, something around 300 would do.
Regards, Stéphane
精彩评论