Trespass ViewGroup Animation Limitations

I have an ImageView inside a RelativeLayout. ImageView fills the entire RelativeLayout. RelativeLayout can't get bigger.

I want the ImageView to use ScaleAnimation more:

final ScaleAnimation scaleAnimationGoBigger = new ScaleAnimation(1, 1.5f, 1, 1.5f,        Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5);
scaleAnimationGoBigger.setDuration(1000);
scaleAnimationGoBigger.setFillAfter(true);
myImageView.startAnimation(scaleAnimationGoBigger);

      

RelativeLayout deviations prevent the entire new larger ImageView from showing, showing only the parts that fit the RelativeLayout (making it look like a zoom effect).

So my question is, is there a way to show a View in a ViewGroup so as not to obey (to violate) the boundaries of the ViewGroup where it lies (at least during animation)?

+3


source to share


1 answer


is there a way to show the View in the ViewGroup so as not to obey (to violate) the border of the ViewGroup where it is ...

Yes. Let's say you have a View ( myImageView

) inside some ViewGroup ( viewGroupParent

). Just calledsetClipChildren(false)

    ViewGroup viewGroupParent = (ViewGroup) myImageView.getParent();
    viewGroupParent.setClipChildren(false);

      

More info here: http://developer.android.com/reference/android/view/ViewGroup.html#attr_android:clipChildren



(at least during animation)?

Use Animation.AnimationListener , it should look something like this:

final ViewGroup viewGroupParent = (ViewGroup) myImageView.getParent();
viewGroupParent.setClipChildren(false);

final ScaleAnimation scaleAnimationGoBigger = new ScaleAnimation(1, 1.5f, 1, 1.5f,        Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5);
scaleAnimationGoBigger.setDuration(1000);
scaleAnimationGoBigger.setFillAfter(true);
scaleAnimationGoBigger.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            viewGroupParent.setClipChildren(false);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // uncomment here if you want to restore clip : viewGroupParent.setClipChildren(true);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // do nothing
        }
    });
myImageView.startAnimation(scaleAnimationGoBigger);

      

HTHS!

+1


source







All Articles