RelativeLayout relativeLayout = findViewById(R.id.relativeLayout); TextView textView = findViewById(R.id.textView); int childCount = relativeLayout.getChildCount(); textView.setText("Child Count: " + childCount);
RelativeLayout relativeLayout = findViewById(R.id.relativeLayout); int childCount = relativeLayout.getChildCount(); for (int i = 0; i < childCount; i++) { View childView = relativeLayout.getChildAt(i); relativeLayout.removeView(childView); }This example shows how to use the `getChildCount` and `removeView` methods of the `RelativeLayout` to remove all the child views present in it. The package library used here is `android.view`.