当前位置: 代码迷 >> Android >> xml中不能直接增添ViewGroup吗
  详细解决方案

xml中不能直接增添ViewGroup吗

热度:45   发布时间:2016-04-28 03:57:01.0
xml中不能直接添加ViewGroup吗
我知道可以直接添加一个<View />的,今天想添加个容器类,然后后台动态添加SurfaceView到ViewGroup容器里,不过提示inflate报错了。难道ViewGroup不能直接这么添加吗?


<LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >   
     <ViewGroup
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         />          
</LinearLayout>

------解决思路----------------------
不能, ViewGroup 是一个抽象类,无法直接实例化