Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.creageek:un-material-tab:'
}
dependencies {
implementation("com.github.creageek:un-material-tab:")
}
<dependency>
<groupId>com.github.creageek</groupId>
<artifactId>un-material-tab</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.creageek" % "un-material-tab" % ""
:dependencies [[com.github.creageek/un-material-tab ""]]
I don't have time to maintain this. I basically wrote this small library in a rush, without tests, while working on my own project as a beginner. As a result, there's a lot of things that aren't that great as well as the missing features. Don't really know if I would have some time to finish it completely.
I'd recommend you to use the official TabLayout from Google or another 3rd party library.
If someone wants to pick up where I left off, make a fork of this, notify me and I'll link to your repo here.
<br>A customizable alternative of TabLayout from Support Design library which provides almost the same functionality.
<img src="https://github.com/creageek/un-material-tabs/blob/master/resources/sample.png" width="360">RoundTabLayout#onTabSelected & RoundTabLayout#onTabReselected callbacksIf you have any suggestions - feel free to open an issue.
I. In your build.gradle file add the following dependency:
dependencies {
compile 'com.ruslankishai:unmaterialtabs:0.1a'
}
II. Declare RoundTabLayout inside your layout.xml file:
<com.ruslankishai.unmaterialtab.tabs.RoundTabLayout
android:id="@+id/round_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:accent="@color/colorAccent" />
III. Declare RoundTabLayout with ViewPager in your 'class.java':
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
//set adapter to your ViewPager
viewPager.setAdapter(new TabPagerAdapter(getFragmentManager()));
RoundTabLayout tabLayout = (RoundTabLayout) findViewById(R.id.roundTabLayout);
tabLayout.setupWithViewPager(viewPager);
IV. Override you getPageTitle method in your ViewPager’s adapter to return tab title.
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "First item";
...
}
}
I. In your layout.xml file you can set a few attributes to RoundedTabLayout:
android:background
background attribute (reference to a color).app:accent
app:cornerRadius
circle (default)roundedrectangle0 to 50II. In your class.java you can set some values to customize specific tab:
RoundTab#setIcon method to change icon. You can get RoundTab object via RoundTabLayout#getTab method which accept tab index as parameter. To enable tab icon, you should also use RoundTab#setHasIcon.…
//after initializing RoundTabLayout and ViewPager
RoundTab tab = tabLayout.getTab(0);
Drawable icon = getResources().getDrawable(R.drawable.globe);
tab.setIcon(icon);
//enable icon in current tab
tab.setHasIcon(true);
//repeat this code for another tabs
…
RoundTab#setHasStroke method.…
//after initializing RoundTabLayout and ViewPager
RoundTab tab = tabLayout.getTab(0);
tab.setHasStroke(true);
…
RoundTab#setCornerRadius which accept values from 0 to 50 as a parameter.…
//after initializing RoundTabLayout and ViewPager
RoundTab tab = tabLayout.getTab(0);
tab.setCornerRadius(35);
…
RoundTab#setText which accept String as a parameter.…
//after initializing RoundTabLayout and ViewPager
RoundTab tab = tabLayout.getTab(0);
tab.setText(“Usage example”);
…
The app works just as an example of usage with different options. Will be uploaded to Play Store sooner.
This is my first public repo and first library so I’m trying to keep this code as much clean and well-commented as I can. Feel free to contribute :)
Copyright (C) 2017 Ruslan Kishai
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.