Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 主动变更视图组';使用动画时的限制_Android_Android Layout_Android Animation_Android Viewgroup - Fatal编程技术网

Android 主动变更视图组';使用动画时的限制

Android 主动变更视图组';使用动画时的限制,android,android-layout,android-animation,android-viewgroup,Android,Android Layout,Android Animation,Android Viewgroup,我有一个相对主义者照片。ImageView正在填充整个RelativeLayout。 相对寿命不能变大 我想使用ScaleImation将ImageView放大,如下所示: final ScaleAnimation scaleAnimationGoBigger = new ScaleAnimation(1, 1.5f, 1, 1.5f, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (floa

我有一个相对主义者照片。ImageView正在填充整个RelativeLayout。 相对寿命不能变大

我想使用ScaleImation将ImageView放大,如下所示:

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的边界不允许显示整个新的更大的图像视图,只显示符合RelativeLayout的部分(使其看起来像缩放效果)

所以我的问题是:有没有一种方法可以告诉视图组中的视图不遵守(侵入)视图组所在的边界(至少在动画期间)

有没有办法告诉视图组内的视图不服从(to) 主动变更)视图组所在的边界

对。假设您在某个视图组(
viewGroupParent
)中有一个视图(
myImageView
)。刚刚调用了
setClipChildren(false)

更多信息请点击此处:

(至少在动画期间)

总之,它应该是这样的:

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);

哎呀

谢谢,这解决了我的问题,但如果有一个解决方案,我可以告诉视图不要遵守其父视图组的边界,而不是告诉父视图允许视图这样做,那就太好了,这主要是因为可能有多个视图组会剪辑我的视图,迫使我放置“setClipChildren(false)”到每个将剪辑我的视图的视图组。Android以这种方式提供给您。我同意如果它是您所说的方式,那就太好了,但是您希望循环这个操作,然后在其中创建一个静态util类,这相当简单。另一种方法是创建视图的副本并将其放在PopUpWindow类实现中,您可以完全放弃编写这个util和循环。但这将是另一个问题的答案祝你好运。
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);