被翻译,缩放或旋转子视图消失
我有一个的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.