Created
October 21, 2015 11:10
-
-
Save sunwicked/1f56693b9bcb2084d21a to your computer and use it in GitHub Desktop.
Creating Custom Tabs to add divider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 0; i < tabLayout.getTabCount(); i++) { | |
TabLayout.Tab tab = tabLayout.getTabAt(i); | |
RelativeLayout relativeLayout = (RelativeLayout) | |
LayoutInflater.from(this).inflate(R.layout.tab_layout, tabLayout, false); | |
TextView tabTextView = (TextView) relativeLayout.findViewById(R.id.tab_title); | |
tabTextView.setText(tab.getText()); | |
tab.setCustomView(relativeLayout); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<!-- Tab title --> | |
<TextView | |
android:id="@+id/tab_title" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:gravity="center" | |
/> | |
<!-- Tab divider --> | |
<View | |
android:layout_width="2dp" | |
android:layout_height="match_parent" | |
android:layout_alignParentLeft="true" | |
android:background="@android:color/white" /> | |
</RelativeLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment