You're setting the LayoutParams to WRAP_CONTENT for the second layout, so even though you set the gravity of the inner RelativeLayout to center, your outer LinearLayout is still going to align at the top left and size itself to wrap the content, so everything will end up in the top left.
Remove the LinearLayout from secondlayout.xml, you don't need it. Then change your code to:
View mView = loiViewInflater.inflate(R.layout.secondlayout, null);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER;
addContentView(mView, params);