Javatpoint Logo
Javatpoint Logo

Android TabLayout with FrameLayout

In the previous page, we created a sliding tabs using TabLayout and ViewPager. Here, we are going to create non sliding tabs using TabLayout and FrameLayout.

Items of TabLayout are implemented by adding TabItem of android support design widget.

Example of TabLayout using FrameLayout

Let's create an example of TabLayout using FrameLayout and Fragment.

File: activity.xml

Create an activity.xml file with TabLayout and FrameLayout view components.

File: build.gradle

Now gave the dependency library of TabLayout in build.gradle file.

File: MainActivity.java

Now create different fragment files for all different tabs.

File: HomeFragment.java

File: fragment_home.xml

File: JavaFragment.java

File: fragment_java.xml

File: AndroidFragment.java

File: fragment_android.xml

File: PhpFragment.java

File: fragment_php.xml

File: strings.xml

Output

android tablayoutwithframelayout1 1
android tablayoutwithframelayout1 2
Next TopicAndroid SearchView




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA