1

私は数日前から問題に悩まされており、似たようなことについて話している人を見つけることさえほとんどできません。実際、長い本や記事を読んだ後でもかなり混乱しているので、バズーカで蚊を殺そうとしているだけかもしれません:-)、しかし、解決策を見つけることができません.

これは私が最後に取得したいものです:

ラウチャーなどのアイコンのリストがあります.2行16列のマトリックスに配置されているとしましょう。アイコンの 1 つを押すと、押されたアイコンをフルスクリーンにズームするアニメーションが開始されます。実際には、アニメーション中にアイコンのグラフィックを維持する必要はありません。アイコンのサイズからフルスクリーンに拡大するボックスであってもかまいません。

私はそのようなアイコンを配置する仕事をしようとしました(これは問題を見るのに十分な2x4マトリックスです)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" android:paddingTop="50dp">
<ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/scrollView">
    <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
                android:gravity="center_horizontal" android:layout_margin="5dp">
            <package.libraries.BoxX
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/boxX"
                  android:src="@drawable/icon1"
                  android:focusableInTouchMode="false" android:layout_weight="1" android:layout_gravity="center"
                  android:clickable="false" android:longClickable="false"
                  android:layout_alignParentLeft="false" android:layout_alignWithParentIfMissing="false"
                  android:layout_margin="10dp"/>
            <package.libraries.BoxX
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/boxX2"
                  android:src="@drawable/icon2"
                  android:focusableInTouchMode="false" android:layout_gravity="center" android:layout_weight="1"
                  android:longClickable="false" android:layout_alignParentRight="false"
                  android:layout_alignParentBottom="false" android:layout_alignParentLeft="false"
                  android:layout_alignParentTop="false"
                  android:adjustViewBounds="false" android:layout_toRightOf="@+id/boxX"
                  android:baselineAlignBottom="false"
                  android:layout_margin="10dp"/>
        </RelativeLayout>
        <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
                android:gravity="center_horizontal" android:layout_margin="5dp">
            <view android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  class="package.libraries.BoxX" android:id="@+id/boxX3" android:src="@drawable/icon3"
                  android:layout_margin="10dp"/>
            <view android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  class="package.libraries.BoxX" android:id="@+id/BoxX4" android:focusableInTouchMode="false"
                  android:src="@drawable/icon4" android:layout_toRightOf="@+id/boxX3" android:layout_margin="10dp"/>
        </RelativeLayout>
    </LinearLayout>
</ScrollView>

package.libraries.BoxX は、ImageView を拡張してアニメーションを実行するカスタム ビューです。これは、アニメーションを作成して実行する方法です。

@Override
public void onClick(View view) {
    XxFlipAnimator animator = new XxFlipAnimator(BoxX.this, strDrw, endDrw,
            BoxX.this.getWidth() / 2, BoxX.this.getHeight() / 2, true);
    animator.setFillAfter(true);
    animator.setFillEnabled(true);
    animator.setDuration(500);
    BoxX.this.startAnimation(animator);
    mStatus = status.CLICKED;
}

XxFlipAnimator は、この ApplyTrasformation メソッドを持つ this から派生した私のアニメーション クラスです

   protected void applyTransformation(float interpolatedTime, Transformation t) {
            final Matrix matrix = t.getMatrix();

    camera.save();
    camera.translate(0.0f, 0.0f, (float) (1100.0 * (0.5f - interpolatedTime)));

    if ((interpolatedTime < 0.5f) || !(zoom))
        camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}

ズームは z 軸で負になることを取得します。ここで最初の質問が来ます: これは正しいですか? これがアイコンを「成長」させる正しい方法である場合、実際のz軸範囲はどれですか? 実験的に定数 1100 を見つけましたが、何らかの仕様が欲しいです。

ちなみに、本当の問題は、アイコンを押すとアニメーションがうまく開始され、アイコンのサイズが大きくなり始めますが、親の相対レイアウトに達するとクランプされます。Linear に変更しようとした結果は同じなので、相対的なレイアウトに関連するものではありません...ポイントは、アニメーションをアニメーションビューの親レイアウトの寸法の外に出すことは可能ですか?

助けてくれる人に感謝します。

クリスティアーノ

4

0 に答える 0