1

私は AdaptorViewFlipper を使用しています。

そのメソッドは、.xml を持つ XML のリソース ID を想定していsetInAnimation()ます。setOutAnimation()ObjectAnimator

アニメーションでビューを同時にスケーリングおよびフェードさせたい。

私はこれを定義しますscale_in_animator.xml(例のために、私はインアニメーションのみを投稿し、アウトアニメーションはちょうど逆です)

<?xml version="1.0" encoding="utf-8"?>
<objectAnimator
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:propertyName="transitionScaleIn"
    android:valueFrom="0"
    android:valueTo="1"
    android:valueType="floatType" />

のアダプタによって返されるビューには、AdaptorViewFlipper次の関数が含まれます。

public void setTransitionScaleIn(float value) {
    setScaleX(2-value);
    setScaleY(2-value);
    setAlpha(value);
}

しかし、何も起こりません。setTransitionScaleIn呼び出されることはありません。

私は何か間違ったことをしていますか?

4

1 に答える 1

1

AdapterViewFlipperのソース コードから:

  .
  .
  // We wrap the new view in a FrameLayout so as to respect the contract
  // with the adapter, that is, that we don't modify this view directly
  FrameLayout fl = getFrameForChild();
  .
  .

したがって、各子AdapterViewFlipperビューを 内にラップするFrameLayoutため、 AdapterViewFlipper を拡張してこの関数をオーバーライドする必要がありました。

FrameLayout getFrameForChild() {
    return new FrameLayoutAnimable(getContext());
}

もちろん、すべての setXXXXX メソッドでFrameLayoutAnimable拡張するクラスを作成します。FrameLayout

NOTE->getFrameForChildはパッケージ メソッドであるため、拡張AdapterViewFlipperandroid.widgetパッケージ内にある必要があります。

于 2014-09-12T17:36:51.763 に答える