TabControllerAndroid by Appolica
This library provides an easy to use API for switching between fragments that share the same container. Implementing tabs, such as the ones Instagram has at the bottom of the layout, is a much simpler goal to achieve when using TabController. Tabs can be switched by using either show/hide or attach/detach. You can even provide your own implementation of the way tabs are being shown.
The library is developed and maintained by Appolica.
Note: The sample uses BottomBar in order to give a nice example of using this library. TabController is for managing fragments and does not provide any UI views.
Download
Gradle
dependencies {
...
compile 'com.appolica:tab-controller:1.0.3'
}
Example
There are two ways of using this library. One is to use TabControllerFragment
. It encapsulates all the fragments and their container into a single fragment.
You can use it like any other fragment by adding it to the xml layout:
<fragment
android:id="@+id/fragment"
android:layout_width="0dp"
android:layout_height="0dp"
class="com.appolica.tabcontroller.fragment.TabControllerFragment"/>
or instantiating it and adding it by yourself:
final TabControllerFragment controllerFragment = new TabControllerFragment();
getSupportFragmentManager()
.beginTransaction()
.add(conainerId, controllerFragment)
.commitNow();
Obtain the TabController instance simply like this:
final TabController tabController = controllerFragment.getTabController();
The other way is to provide your own fragment container. If you choose to use this, you have to create the TabController instance by yourself:
finalTabController tabController =newTabController(getSupportFragmentManager(), R.id.container);