I would like to know if is there a way to call android:layout_gravity property from a Java method. I didn\'t found any method in Android documentation to do it.
To change the layout_gravity attribute for an existing view:
Button button = (Button) findViewById(R.id.some_button);
FrameLayout.LayoutParams params;
params = (LayoutParams) button.getLayoutParams();
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
button.setLayoutParams(params);
The button is contained in a FrameLayout which has a gravity attribute corresponding to the layout_gravity XML attribute. Documentation link.