Android在代码中使用布局文件中的一个组件

使用前必须要把组件与其父组件的关系断开,比如有一个组件的名称为scrollChildLayout,则可以使用下面的代码进行分离

((ViewGroup)scrollChildLayout.getParent()).removeView(scrollChildLayout);
view.addView(scrollChildLayout);

 程序猿必读

原文地址:https://www.cnblogs.com/longzhongren/p/6253401.html