In fact, by default the tabs are in the shape of a rectangle, but I want to create a custom shape. I did some encoding, but now there is a space between the tabs, and I want them all to be together. Please, help!
What I've done
But what I'm trying to do :
MainActivity.java
final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.addTab(tabLayout.newTab().setText("First"));
tabLayout.addTab(tabLayout.newTab().setText("Second"));
tabLayout.addTab(tabLayout.newTab().setText("Third"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
activity_main.xml
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="27dp"
android:minHeight="?attr/actionBarSize"
app:tabBackground="@drawable/customtabhandler"
/>
customtabhandler.xml
<?xml version="1.0" encoding="utf-8"?>
<item android:state_selected="false"
android:drawable="@drawable/defualttab" />
<item android:state_selected="true"
android:drawable="@drawable/onselectedtab" />
defualttab.xml
<item>
<shape android:shape="rectangle">
<size
android:width="95dp"
android:height="20dp" />
<solid android:color="#ff30a3b6" />
</shape>
</item>
onselectedtab.xml
<item>
<shape android:shape="rectangle">
<size
android:width="95dp"
android:height="20dp" />
<solid android:color="#89aaaaaa" />
</shape>
</item>
<item
android:right="100dp"
android:left="-100dp"
android:top="-100dp"
android:bottom="-100dp">
<rotate
android:fromDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#ff30a3b6" />
</shape>
</rotate>
</item>
<item
android:right="-100dp"
android:left="100dp"
android:top="-100dp"
android:bottom="-100dp">
<rotate
android:fromDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#ff30a3b6" />
</shape>
</rotate>
</item>
Any help would be greatly appreciated.
PS I searched a lot in stackoverflow, and everything I found was for the old library, but not for the new one.
source
share