在一个片段中,我使用多个子视图来扩展布局。我需要获取其中之一的尺寸(宽度和高度),这是一个自定义视图。
在自定义视图类中,我可以很容易地做到这一点。但是如果我尝试从片段开始,我总是得到0作为维度。
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
View culoide = view.findViewWithTag(DRAW_AREA_TAG);
Log.d("event", "culoide is: "+culoide.getWidth()); // always 0
}
我认为onViewCreated应该是获得它的正确地方,但这种情况确实发生了。我在super.onViewCreated之前尝试过,在debug中看起来'findViewWithTag‘找到了正确的视图,只尝试了API7 v4支持。
有什么帮助吗?
https://stackoverflow.com/questions/16925317
复制相似问题