如何动态编辑fragment的高度,宽度和margin?

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.

posted @ 2013-02-01 16:10  __木头鱼__  阅读(2765)  评论(0编辑  收藏  举报