I am creating FrameLayout dynamically using the following code
mylayout.java
FrameLayout layout = new FrameLayout(this); FrameLayout.LayoutParams layoutp
Add
layout.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
or
layout.setGravity(Gravity.CENTER);
You forgot to set the gravity of the layout.