http://stackoverflow.com/questions/10683374/set-fragments-parameters-programatically-in-android
How to set parameters like height, width ,margins for fragments programatically?
Fragments do not have "parameters like height, width ,margins". View
and ViewGroup
have "parameters like height, width ,margins". So, you either adjust the container into which you are placing the fragment (which, for some strange reason, you have declared as 1
in your examples above), or you adjust the View
that your Fragment
returns from onCreateView()
.
"But we can set parameters for fragment in xml"
that is shorthand for setting parameters on the view returned by onCreateView()
. Fragment
is not a View
and so does not have height, width, etc.