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>

============解决方案1============


不能, ViewGroup 是一个抽象类,无法直接实例化
原文地址:https://www.cnblogs.com/lianxu61/p/4046270.html