2

私はしばらくの間、この問題の良い解決策を見つけようとしてきましたが、それを理解することはできませんでした.翌年の Google 割り当てを使い果たしました。

基本的に、私が達成したいのは、個々のビューの ScaleAnimation です。これは、長押しすると、拡大してから縮小して、それが押されたことを示します。

以上でセットアップは完了です。問題ありません。

問題は、ScaleAnimation がビューの親によってクリップされ、その親に拡張されないことです。階層は次のとおりです。

Relative > 
    Relative >
        Linear >     (<-- The animation is cut at the outer bounds of this parent)
            View

私は android:clipChildren="false" と android:clipPadding="false" を追加しようとしましたが、これらのソリューションのどちらも、最初の親の境界の外で実際にアニメーション化するのに役立ちませんでした。

トゥイーン アニメーションは、アニメーション化されたビューがあるビューの境界を超えないように設計されていることは理解していますが、それは不可能であり、ドラッグ可能なビューのようなもので見ることができますか?

それとも、この状況に完全に間違ってアプローチしているだけですか?

最初の親の境界を超えて実際にアニメーション化するにはどうすればよいでしょうか?

助けてくれてありがとう、-マット

4

1 に答える 1

0

ハックではありますが、私が思いついた唯一の解決策はまだ機能しています。

親は RelativeLayout であり、他のコンテンツの上に z 配置された非表示の Custom TextView があります。アニメーションを呼び出す必要がある場合は、アニメーション化する必要があるビューと同じ LayoutParams/background/text を TextView に与え、それを View.VISIBLE に設定してアニメーション化し、アニメーションが完了したら View.GONE に戻します。 :

public void doAnimation(final View v){      
    v.setId(5); 
    final CustomTextView animatorImage = (CustomTextView) ((MainActivity)mActivity).findViewById(R.id.pick_animator_image); // Our hidden TextView in the FrameLayout
    try{
        animatorImage.setBackgroundDrawable(v.getBackground());
        animatorImage.setText(((TextView)v).getText().toString());
        animatorImage.setTextColor(((TextView)v).getCurrentTextColor());
        animatorImage.setTextSize(TypedValue.COMPLEX_UNIT_PX, ((TextView)v).getTextSize());
    }
    catch(Exception e){

    }

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(v.getWidth(), v.getHeight());
    int[] windowLocation = new int[2];
    v.getLocationInWindow(windowLocation);

    params.leftMargin = (int) windowLocation[0];
    params.topMargin = (int) windowLocation[1] - ((MainActivity)mActivity).getSupportActionBar().getHeight() - getStatusBarHeight(); // Subtract the ActionBar height and the StatusBar height if they're visible

    animatorImage.setLayoutParams(params);
    animatorImage.setVisibility(View.VISIBLE);

    v.setVisibility(View.INVISIBLE);

    ScaleAnimation scaleAnim = new ScaleAnimation(1f, 2.5f, 1f, 2.5f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleAnim.setDuration(300);
    scaleAnim.setZAdjustment(Animation.ZORDER_TOP);
    scaleAnim.setAnimationListener(new AnimationListener(){
        public void onAnimationEnd(Animation arg0) {

            ScaleAnimation scaleAnim2 = new ScaleAnimation(2.5f, 1f, 2.5f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            scaleAnim2.setDuration(300);
            scaleAnim2.setZAdjustment(Animation.ZORDER_TOP);
            scaleAnim2.setAnimationListener(new AnimationListener(){
                public void onAnimationEnd(Animation animation) {
                    animatorImage.clearAnimation();
                    v.setVisibility(View.VISIBLE);
                    animatorImage.setVisibility(View.GONE);
                }

                public void onAnimationRepeat(Animation animation) {

                }

                public void onAnimationStart(Animation animation) {

                }});

            animatorImage.startAnimation(scaleAnim2);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {

        }});

    animatorImage.bringToFront();
    animatorImage.startAnimation(scaleAnim);
}

XML 階層は次のとおりです。

RelativeLayout (parent)
    ViewGroup (main content body)
    TextView (hidden View to animate)

「R.id.pick_animator_image」を TextView の ID が RelativeLayout にあるものに変更し、アニメーション化するビューでそのメソッドを呼び出すだけで、これで偽装できます。

于 2013-10-09T14:45:56.190 に答える