我也碰到这个问题啊,只能显示VIEW

解决方案 »

  1.   

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // TODO Auto-generated method stub
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
    getChildAt(i).measure(widthMeasureSpec, heightMeasureSpec);
    }
    }
    填上这个就可以了
      

  2.   

    //心中疑惑:我认为我只要在这里调用child的layout(int,int,int,int)方法给出它的位置和宽高就可以了
    //如果child本身是一个ViewGroup的话它是否应该自己去管理它本身内部的child的位置和宽度呢???
    同样疑惑求高手解答。。遇到同样问题了~~~
      

  3.   

    我在ViewGroup下边放置一个TextView设置文本框中文字的对齐方式不管用···
      

  4.   

    调用 ViewGroup.addView(View child, ViewGroup.LayoutParams params) 就可以了。后面要添加LayoutParams 参数。( LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);)ViewGroup嵌套其它布局时子view的宽度和高度默认为wrap_content。 mvg.addView(view,new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));