0

My TabLayout is:

<com.google.android.material.tabs.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/color_nav_bar_gray"
            app:tabTextColor="@color/colorBlack"
            app:tabGravity="fill" />

Also, I am adding tab item like this using this java code:

TabLayout tabLayout =findViewById(R.id.tabLayout);
        tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.ic_menu_black));
        tabLayout.addTab(tabLayout.newTab().setText(selectedFolder));
        tabLayout.addTab(tabLayout.newTab().setText("Calender"));
        final MainPageTabLayoutAdapter adapter = new 
        MainPageTabLayoutAdapter(this,getSupportFragmentManager(), tabLayout.getTabCount());
        viewPager.setAdapter(adapter);

    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    viewPager.setCurrentItem(1);
    

It is showing something like this: enter image description here

But I want to make it something like this with the default swipe animation[left to right] / [right to left] of tab change of a tab layout.

How to make first tab item width less than the other tab item as per below image

Prantik Mondal
  • 483
  • 4
  • 14

0 Answers0