我正在尝试自定义我的FragmentTransaction转换,我遇到了setTransitionStyle方法。它使用xml资源id作为样式,但我不知道xml资源会是什么样子。我知道您可以为活动定义动画样式,而且我假设此方法所需的xml类似,但我无法找到任何关于所需格式的文档(例如,需要xml属性/节点来完成此工作)。
EDIT1 (这是我现在在FragmentActivity中所做的):
public void pushFolderFrag(Fragment folderFrag, String backStackID) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.SplitView_MasterContainer, folderFrag);
transaction.addToBackStack(backStackID);
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
//transaction.setTransitionStyle(arg0);//what does the format for this resource look like??
// Commit the transaction
transaction.commit();
}发布于 2016-02-12 15:24:03
我在这个链接上找到了答案
https://github.com/kedzie/Support_v4_NineOldAndroids
转换类型资源
在样式资源中指定转换动画。
创建一个样式资源‘`res/value/styes.xml’,指定事务中的资源和转换
tx.setTransitionStyle(R.style.MyTransitionStyle);tx.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
发布于 2012-05-23 12:48:23
我知道这并不能确切地回答这个问题,但是为什么不使用setCustomAnimations()呢?
如果使用Android 3+,则使用 resources,如果使用支持包,则使用 resources。
https://stackoverflow.com/questions/8345089
复制相似问题