-
Notifications
You must be signed in to change notification settings - Fork 2.1k
1. 如何开始?
YoKey edited this page Dec 31, 2017
·
8 revisions
1. 项目下app的build.gradle中依赖:
// appcompat-v7包是必须的
compile 'me.yokeyword:fragmentation:{最新版}'
// 如果不想继承SupportActivity/Fragment,自己定制Support,可仅依赖:
// compile 'me.yokeyword:fragmentation-core:{最新版}'
// 如果想使用SwipeBack 滑动边缘退出Fragment/Activity功能,完整的添加规则如下:
compile 'me.yokeyword:fragmentation:{最新版}'
// swipeback基于fragmentation, 如果是自定制SupportActivity/Fragment,则参照SwipeBackActivity/Fragment实现即可
compile 'me.yokeyword:fragmentation-swipeback:{最新版}'
2. Activity继承SupportActivity:
// v1.0.0开始,不强制继承SupportActivity,可使用接口+委托形式来实现自己的SupportActivity
public class MainActivity extends SupportActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(...);
// 栈视图等功能,建议在Application里初始化
Fragmentation.builder()
// 显示悬浮球 ; 其他Mode:SHAKE: 摇一摇唤出 NONE:隐藏
.stackViewMode(Fragmentation.BUBBLE)
.debug(BuildConfig.DEBUG)
...
.install();
if (findFragment(HomeFragment.class) == null) {
loadRootFragment(R.id.fl_container, HomeFragment.newInstance()); // 加载根Fragment
}
}
3. Fragment继承SupportFragment:
// v1.0.0开始,不强制继承SupportFragment,可使用接口+委托形式来实现自己的SupportFragment
public class HomeFragment extends SupportFragment {
private void xxx() {
// 启动新的Fragment, 另有start(fragment,SINGTASK)、startForResult、startWithPop等启动方法
start(DetailFragment.newInstance(HomeBean));
// ... 其他pop, find, 设置动画等等API, 请自行查看WIKI
}
}