在机器人编程设置片段参数 [英] Set fragments parameters programatically in android
问题描述
如何设置一样的高度,宽度,编程利润率片段参数。我加入的碎片像
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
MyListFragment myListFragment =新MyListFragment();
fragmentTransaction.add(1,myListFragment);
DetailFragment detailFragment =新DetailFragment();
fragmentTransaction.add(1,detailFragment);
fragmentTransaction.commit();
另外我使用compatabilty罐子像Android的支持 - v4.jar。
感谢。
如何设置一样的高度,宽度,边距参数片段编程
片段没有参数,如高度,宽度,利润。 查看
和的ViewGroup
有参数,如高度,宽度,利润。所以,你要么调整容器,其中上放置片段(其中,一些奇怪的原因,你已经声明为 1
在上面的示例),或者调整查看
,从 onCreateView你的
。片段
返回()
How to set parameters like height, width ,margins for fragments programatically. I am adding fragments like
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
MyListFragment myListFragment = new MyListFragment();
fragmentTransaction.add(1, myListFragment);
DetailFragment detailFragment = new DetailFragment();
fragmentTransaction.add(1, detailFragment);
fragmentTransaction.commit();
Also I am using compatabilty jar like android-support-v4.jar.
Thanks.
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()
.
这篇关于在机器人编程设置片段参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!