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.
Well as far as I understand you looking for this It is for FrameLayout for other layout see appropriate LayoutParams classes. For setting gravity like in your XML use something like:
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,Gravity.LEFT | Gravity.CENTER_VERTICAL)
followed by addView with newly constructed LayoutParams