被翻译,缩放或旋转子视图消失 [英] Child Views that are translated, scaled or rotated disappear

查看:86
本文介绍了被翻译,缩放或旋转子视图消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的ViewGroup 和我添加子视图,以这样的:

I have a ViewGroup and I'm adding child Views to it like this:

mViewGroup.addView(view, new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));

(即 WRAP_CONTENT onclicklistener 按预期方式工作很重要)。

(the WRAP_CONTENT is important for the onclicklistener to work as expected).

到目前为止好,但后来我周围的动态通过重写他们的的onDraw 方法或通过覆盖ViewGroups移动子视图:

So far so good, but later I move the child Views around dynamically by either overriding their onDraw methods or by overriding the ViewGroups:

protected boolean getChildStaticTransformation(View child, Transformation t)

的问题是,在儿童中消失,如果他们似乎当它们首先被添加到计算其原始区域的外侧移动。我打过电话 setClipChildren(假); ,但没有奏效。

我可以通过解决问题添加儿童在 LayoutParams.FILL_PARENT 的意见,但在这种情况下, onClickListener 将任何反应,点击整体上的ViewGroup ,我希望它只是点击反应在哪里我的孩子转变查看所在的特定区域。

I could solve the problem by using LayoutParams.FILL_PARENT when adding the child views but in this case the onClickListener would react to any click on the whole ViewGroup and I want it to only react to clicks on the specific area where my transformed child View is located.

也许我仍然可以使用 LayoutParams.FILL_PARENT 如果有一种方法来定义的查看可点击区域应该的。

Maybe I could still use LayoutParams.FILL_PARENT if there is a way to define where the clickable region for the View should be.

有什么建议?

推荐答案

也许你应该与你的孩子的意见边距和补实验。否则,你可以尝试使用不同的ViewGroup布局一样可以看到每个角度的现在的位置是可以通过其边距设置的FrameLayout。

Perhaps you should experiment with margins and paddings of your child views. Otherwise you could try to use a different ViewGroup layout like a FrameLayout where the postion of each view can be set by its margins.

这篇关于被翻译,缩放或旋转子视图消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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