// Get the parent layout LinearLayout parentLayout = findViewById(R.id.parent_layout); // Get the child view that need to be removed TextView childTextView = findViewById(R.id.child_text_view); // Remove the child view from the parent layout parentLayout.removeView(childTextView);
// Get the parent layout RelativeLayout parentLayout = findViewById(R.id.parent_layout); // Remove all child views from the parent layout parentLayout.removeAllViews();
// Get the parent layout FrameLayout parentLayout = findViewById(R.id.parent_layout); // Get the index of the child view that needs to be removed int childIndex = 0; // 0 represents the first child view // Remove the child view from the parent layout using its index parentLayout.removeViewAt(childIndex);Package library: android.widget