I'm new to android app development and implemented a SlidingTabLayout. I want to display a floating button in one of the tab but unable to do so. I've tried including my button in my tab fragment as well as my main activity. In mainactivity, when I switch tabs, the buttons is still included in the second tab. I tried floatingbutton.show() and hide in my tab change listener but of no use. Any help will be appreciated.My activity_main.xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout" android:layout_height="match_parent"
android:layout_width="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.pegasus.tabstutorial.MainActivity">
<include
android:id="@+id/app_bar"
layout="@layout/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.pegasus.tabstutorial.SlidingTabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryColor" />
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@mipmap/ic_launcher"
app:layout_anchor="@+id/appbarLayout"
app:layout_anchorGravity="bottom|right|end"
android:layout_marginBottom="37dp"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
<fragment
android:layout_width="280dp"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_navigation_drawer"
android:id="@+id/navDrawer"
android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>`
and my home_tab.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="You Are In Tab Home Tab"
android:id="@+id/textView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>