put this in the XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/home_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/white"
app:tabPadding="10dp"
android:minHeight="100dp"
app:tabGravity="fill"
app:tabIndicatorColor="@color/app_primary_color"
app:tabMode="fixed"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
and this in the code
try
{
tabLayout.addTab(tabLayout.newTab());
tabLayout.addTab(tabLayout.newTab());
tabLayout.addTab(tabLayout.newTab());
tabLayout.addTab(tabLayout.newTab());
tabLayout.getTabAt(0).setIcon(R.drawable.tab_icon1);
tabLayout.getTabAt(1).setIcon(R.drawable.tab_icon2);
tabLayout.getTabAt(2).setIcon(R.drawable.tab_icon3);
tabLayout.getTabAt(3).setIcon(R.drawable.tab_icon4);
}
catch (Exception e)
{
Log.e("TabLayout Creation Error",e.getMessage());
}
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
switch(tabLayout.getSelectedTabPosition())
{
case 0:
break;
case 1:
//Do the stuff
break;
case 2:
//Do the stuff
break;
case 3:
//Do the stuff
break;
}
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
7
solved Is it possible to implement bottom tab bar functionality like iOS in android? [closed]