Dynamically adding Relative layout into Linear layout

I am not sure where getRootView() resides in your code. If you clarify, I can provide better solution.

However, I created a project with navigation drawer activity, defined the RelativeLayout to be added dynamically in layout_to_be_added.xml, and did the following experiment in onCreate() of MainActivity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ...

    final LinearLayout contentPanel = findViewById(R.id.contentPanel);
    contentPanel.post(new Runnable() {
        @Override
        public void run() {
            View layoutToBeAdded = LayoutInflater.from(MainActivity.this).inflate(R.layout.layout_to_be_added, null);
            contentPanel.addView(layoutToBeAdded);
            // contentPanel.invalidate();
        }
    });
}

This resulted in the problem you mentioned, progress bar and text is not below the centered logo, as seen here:

Probably the layout params are not correct....

It seems null root causes wrong calculations or evaluations, therefore I updated inflate() line as follows:

View layoutToBeAdded = LayoutInflater.from(MainActivity.this).inflate(R.layout.layout_to_be_added, contentPanel, false);

Here we provide container as root but we don't attach slider layout to it. This way the root is only used to calculate correct LayoutParams and we get the expected result as seen below:

Correct result