离开父级时,Android 视图消失 [英] Android View Disappearing When Go Outside Of Parent

查看:21
本文介绍了离开父级时,Android 视图消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这个 LinearLayout 中有一个 LinearLayout 和 ImageView.

I have a LinearLayout and ImageView inside this LinearLayout.

ImageView 有翻译效果.

There is a translation effect for ImageView.

// v = ImageView    
ObjectAnimator animation2 = ObjectAnimator.ofFloat(v, "translationY", 200);
                        animation2.setDuration(3000);
                        animation2.setTarget(v);
                        animation2.start();

动画工作但当 ImageView 超出 LinearLayout 时它消失了.

Animation working but it's disappearing when ImageView go outside of LinearLayout.

如何在不修改 LinearLayout 高度的情况下修复它.

How can i fix it without modify LinearLayout's height.

推荐答案

找到 ImageView 所属的 ViewGroup 并应用 ViewGroup.setClipChildren(false).默认情况下,子视图的绘制仅限于父视图组的边界.

Find the ViewGroup that the ImageView belongs to and apply ViewGroup.setClipChildren(false). By default, the drawing of the children is limited to the bounds of the parent ViewGroup.

这篇关于离开父级时,Android 视图消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆