2

これは私のxmlです:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <SurfaceView
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="0dp" />

</RelativeLayout>

時代とともにこの景色を育んでいきたい。

ここにアニメーションのコードがあります

SurfaceView surfaceViewTimer = (SurfaceView) findViewById(R.id.surface_view_timer);
Animation surfaceGrowingAnimation = new TranslateAnimation
    (0, 0, Animation.ZORDER_TOP, 300);
surfaceGrowingAnimation.setDuration(5000);

surfaceViewTimer.startAnimation(surfaceGrowingAnimation);

このアニメーションを画面の下から上に移動させたいと思います。現在、上から下に向かっています。

4

3 に答える 3

2

を使用できますScaleAnimation

たとえば、サーフェスが画面全体を占めるようにレイアウトを変更します。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<SurfaceView
    android:id="@+id/surface"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="0dp"
    android:background="@color/red"
     />

次に、Y軸で0から1にスケーリングします。

    SurfaceView surface = (SurfaceView) findViewById(R.id.surface);

    ScaleAnimation animation = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f);
    animation.setDuration(5000);
    surface.startAnimation(animation);
于 2012-11-23T15:15:28.533 に答える
1

TranslateAnimation次のようにして実行できます。

    final SurfaceView surface = (SurfaceView) findViewById(R.id.surface);

    surface.post(new Runnable() {
        @Override
        public void run() {
            TranslateAnimation translation = new TranslateAnimation(0f, 0f, surface.getHeight(), 0f);
            translation.setDuration(2000);
            surface.startAnimation(translation);
        }
    });
于 2012-11-23T15:43:47.973 に答える
1

スケーリングと移動アニメーションを組み合わせることでそれを行うことができます。移動アニメーションはビューの位置の変更に役立ち、アニメーションのスケールはサイズの変更に役立ちます。そして、コードで Accelerate_Decelerate インターポレーターを使用します。補間器は必要な効果を与えます。さまざまなタイプの利用可能なインターポレーターを試して、効果を得ることができます。

于 2012-11-23T17:04:31.497 に答える