【发布时间】:2015-07-20 17:31:21
【问题描述】:
我有一个自定义 FrameLayout,在 xml 文件中它有 2 个孩子(它们都是 RelativeLayout,它们相互重叠)
在drawChild 方法中我这样做
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
if(view.equals(firstChild){
return super.drawChild(canvas, child, drawingTime);
}else {
//...do some thing with mPath like adding a circle to it
canvas.clipPath(mPath);
return super.drawChild(canvas, child, drawingTime);
}
}
但是我从 Logcat 得到了这两行代码:
requestLayout() improperly called by android.widget.RelativeLayout{c1a8b57 V.E...... ......ID 0,0-1080,210} during second layout pass: posting in next frame
requestLayout() improperly called by android.widget.RelativeLayout{c1a8b57 V.E...... ......ID 0,0-1080,210} during layout: running second layout pass
我知道clipPath 有问题(可能重叠),因为通过评论此行canvas.clipPath(mPath); 警告消失了。
有什么想法吗?
【问题讨论】:
-
“如果我将第二个孩子的可见性更改为 GONE”,这将导致第二个孩子永远无法测量、布局和绘制。
-
@petey 是的,我知道,我编辑了我的问题
标签: android