[英]Android viewGroup listen to child view visibility changes
I have an android custom ViewGroup
我有一个android自定义
ViewGroup
I need to receive children visibility
changes and then make some change to my logic and ... 我需要接收孩子的
visibility
更改,然后对我的逻辑进行一些更改,并...
for example: I set view1
in a RelativeLayout
above view2
and when view2
set it's visibility
to GONE
I must change view1
design roles and ... 例如:我设定
view1
在RelativeLayout
上述view2
,当view2
设置它的visibility
,以GONE
我必须改变view1
设计角色和...
In your custom ViewGroup
, you might have overriden onLayout()
and onMeasure()
. 在自定义
ViewGroup
,您可能已覆盖onLayout()
和onMeasure()
。 Inside these methods you could just get how many child are there and they visibility status. 在这些方法中,您可以得到那里有多少个孩子,并且它们的可见性状态。
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() != GONE) {
// Measure the child or do whatever you want
}
}
More info here: http://developer.android.com/reference/android/view/ViewGroup.html . 此处的更多信息: http : //developer.android.com/reference/android/view/ViewGroup.html 。 There is an example in that page.
该页面中有一个示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.