2011-06-20 18 views
3

私は、シネマの席を並べています。私はある種のズームを行うためにアニメーションのセット(スケールと翻訳)を適用する必要があります。私はすべてのビューにアニメーションを適用します。アニメーションは、次のようになります。私はID scrollable_placesRelativeLayoutに私の意見を入れてアニメーションの終了後にスクロールします。android

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

だから、
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; 

、私のレイアウトは次のようになります。アニメーションの終了後、このビューの一部は画面外に出ますが、スクロールは使用できません。 dimentionsRelativeLayout or other, parent, layoutsに再定義する必要があると思いますが、手動で行う方法はわかりません。 ありがとう!

答えて

3

あなたは、このようなあなたのScrollViewのこの目的のために遅延スクロールを投稿しようとすることができます:

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

それはあなたのアニメーションの終了後に開始するようにフィットするか、を聞いた後、あなたがこれを行うことができるようにアニメーションの最後にAnimationListenerを入れてください。この場合、4300ミリ秒より短い遅延を使用することができます.300周ぐらいの遅延があります。

よろしくお願いします。 ステファン

+0

ありがとう!それはScrollViewでうまく動作しますが、Horizo​​ntalScrollView(レイアウトで親としてScrollViewを持つ)で同じトリックを実行したい場合は、View.FOCUS_DOWNをView.FOCUS_RIGHTに置き換えただけです。これは動作しません。私のレイアウトに何か間違いがありますか? – arbuzz

+0

また、あなたのレイアウトに関する質問もここにあります。このスレッドは、水平および垂直のスクロールに関するものです。 http://stackoverflow.com/questions/2044775/scrollview-vertical-and-horizo​​ntal-in-android – Snicolas

+0

ありがとう、それは助けた! – arbuzz

関連する問題