百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

FragmentMaster

> 编程语言
开源

帮助您轻松开发一个仅通过 Fragment 进行导航的 Android 应用程序。

186 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

帮助您轻松开发一个仅通过 Fragment 进行导航的 Android 应用程序。

FragmentMaster

FragmentMaster is a library allows you easily develop an Android application which only navigated by Fragments.

Features

  • Pass data and receive result between two fragments.
  • Swipe right to navigate back.
  • Custom transform animation.

Usage

  1. MasterFragment

    In FragmentMaster, every "page" is subclass of MasterFragment (Or other IMasterFragment, like MasterListFragment) not Activity.

    1. You can start a MasterFragment as start a Activity:
    java
    // start YourMasterFragment
    Request request = new Request(YourMasterFragment.class);
    startFragment(request);

    The Request class is similar to the Android's Intent which is an abstract description of your operation. The difference is that Request is used to start a MasterFragment.

    1. You can pass data within two MasterFragments. Put extra data into your request and start YourMasterFragment:
    java
    // pass data.
    Request request = new Request(YourMasterFragment.class);
    request.putExtra(YourMasterFragment.EXTRA_KEY, "Extra data");
    startFragment(request);
    1. And get extra data in YourMasterFragment:
    java
    Request request = getRequest();
    String extraData = request.getStringExtra(YourMasterFragment.EXTRA_KEY);
  2. Install FragmentMaster

    Subclass MasterActivity, it is the host of all MasterFragments. And in its onCreate() add the codes below after setContentView() method:

    java
    setContentView(R.layout.master_activity);
    FragmentMaster fragmentMaster = getFragmentMaster();
    fragmentMaster.install(R.id.container, new Request(Home.class), true);

    The first parameter of install() is the id of your MasterFragment's container. All started MasterFragment will be added to this container. The second parameter is a Request object which describes your home MasterFragment. The home MasterFragment will be started once the host MasterActivity is started. If the third parameter is true, the host MasterActivity will be finished when the home MasterFragment is finished.

  3. PageAnimator

    FragmentMaster provides an API for you to add custom animation for each MasterFragment. The animation will be performed when starting, finishing and dragging by user.

    1. Subclass PageAnimator and implement two methods:
    java
    // Transform the background page.
    protected abstract void transformBackgroundPage(View page, float position,
    boolean enter);
    java
    // Transform the foreground page.
    protected abstract void transformForegroundPage(View page, float position,
    boolean enter);
    1. Override onCreatePageAnimator method of MasterFragment to provide your custom PagerAnimator:
    java
    @Override
    public PageAnimator onCreatePageAnimator() {
        // return your own PageAnimator.
        return YOUR_CUSTOM_ANIMATOR;
    }

    There are some custom PageAnimators in the Sample project.

License

Copyright 2014 Feng Dai

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言