The height of my tablayout is wrap content. But it's not working. I am pasting the screenshot here. It's working OK in mobile phones but not in tab.
This problem was also with width but the tag app:tabMaxWidth="0dp" helped me out. How can i overcome this? here is the code to layout.
<android.support.design.widget.TabLayout
android:id="@+id/tablayout_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMaxWidth="0dp"
android:minHeight="0dp"
android:layout_gravity="bottom"
android:layout_below="@+id/relativeLayout"
app:tabGravity="fill"
app:tabBackground="@drawable/tab_color_selector"
app:tabIndicatorColor="@color/sea_green"
app:tabIndicatorHeight="2dp"
app:tabMode="fixed"
android:clickable="false"
/>
The problem was with the parent of the tablayout. The tablayout was ok. Here is the code for parent item.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_app_white"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<android.support.design.widget.TabLayout
android:id="@+id/tablayout_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMaxWidth="0dp"
android:minHeight="0dp"
android:layout_gravity="bottom"
android:layout_below="@+id/relativeLayout"
app:tabGravity="fill"
app:tabBackground="@drawable/tab_color_selector"
app:tabIndicatorColor="@color/sea_green"
app:tabIndicatorHeight="2dp"
app:tabMode="fixed"
android:clickable="false"/>
</RelativeLayout>