簡體   English   中英

動畫結束后滾動,android

[英]Scrolling after the end of animation, android

我有一系列的觀點,電影院的座位。 我需要對它們應用一組動畫(縮放和平移)來進行某種縮放。 我將動畫應用到每個視圖。 動畫看起來像這樣:

    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;

所以,我的布局看起來像這樣:

<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!"/>

我將我的視圖放入了RelativeLayout其中包含id scrollable_places 因此,在動畫結束后,一些視圖超出了屏幕的范圍,但沒有可用的滾動。 我想我需要重新定義RelativeLayout or other, parent, layoutsdimentions ,但我不知道如何手動完成。 謝謝!

您可以嘗試將滾動延遲滾動到ScrollView的這一端,如下所示:

scrollView.postDelayed( new Runnable() {
                @Override
                public void run() {
                    scrollView.fullScroll( View.FOCUS_DOWN);
                }
            }, 4300);

因此,它適合在動畫結束后開始,或者您可以在使用AnimationListener收聽動畫結束后執行此操作,在這種情況下,您可以使用小於4300毫秒的延遲,大約300的延遲。

此致,Stéphane

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM