如何编程设置片段的高度、宽度、边距等参数。我在添加碎片
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();
另外,我正在使用类似android-support-v4.jar的兼容jar。
谢谢。
最佳答案
如何编程设置片段的高度、宽度、边距等参数
片段没有“高度、宽度、边距等参数”。View
和ViewGroup
具有“高度、宽度、边距等参数”。因此,您要么调整放置片段的容器(出于某种奇怪的原因,您在上面的示例中声明为1
),要么调整View
从Fragment
返回的onCreateView()
。
关于android - 在Android中以编程方式设置 fragment 参数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10683374/