问题描述
在一个按钮上,我这样调用布局:
setContentView(R.layout.my_form);
另一方面,我想破坏这种布局。 我该怎么做 ?
1楼
你可以使用rootView.removeAllViews();
例如,从布局中删除所有视图
您的布局是
<LinearLayout
android:id="@+id/llRootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
.......
</LinearLayout>
然后,您可以调用llRootView.removeAllViews();
从此线性布局中删除所有视图
编辑
要从布局中临时删除视图,您可以使用
llRootView.setVisibility(View.GONE);
要使其再次可见,请使用
llRootView.setVisibility(View.VISIBLE);