devlight / navigationtabstrip Goto Github PK
View Code? Open in Web Editor NEWNavigation tab strip with smooth interaction.
License: Apache License 2.0
Navigation tab strip with smooth interaction.
License: Apache License 2.0
How set bold font for selected item?
thanks
Hello GIGAMOLE,
First of all, Great thank you for sharing this amazing widget 👍
I want to use NavigationTabStrip and NavigationTabBar in the same app.
I wrote build.gradle like below:
repositories {
mavenCentral()
maven {
url 'http://dl.bintray.com/gigamole/maven/'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.github.devlight.navigationtabbar:library:+'
compile 'com.github.devlight.navigationtabstrip:library:+'
}
But it complains that
Error:Execution failed for task ':app:processDebugResources'.
> Error: more than one library with package name 'com.gigamole.library'
So I changed build.gradle like below:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.github.devlight.navigationtabstrip:library:1.0.1'
compile 'com.github.devlight.navigationtabbar:library:1.2.0'
}
But It also complains again there is more than one library with package name 'com.gigamole.library'.
Could you please fix this issue?
Best Regards,
Sungcheold Kim.
Is is possible to implement this? Or how I can achieve this myself?
Titles overlap when used more than 4 tabs. Is there is any option to make scrolling tab.
Hi, Thanks for the library. It looks and works fantastic. One question, though. How can I attach different fragments to different tabs?
Thanks.
In the XML layout file, use
com.gigamole.library.navigationtabstrip.NavigationTabStrip
instead of
com.gigamole.library.NavigationTabStrip
I just want two tabs for my layout.So I have placed only 2 items in titles array.
Ex:-
Tab1
Tab2
But When i slide to right side from 2nd position , dot animation get performed even though there is no 3rd tab. How to solve this , please help.
i am already using your 'com.github.devlight.navigationtabbar:library:1.1.6' and today when i included your this library the below error pop out. Please do need full changes.
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.gigamole.library'
Is there any way for set icon instead of text in the title?
what wrong with the problem?
`mSubaeraTablayout.setTitles(array);
// mSubaeraTablayout.setStripColor(Color.RED);
mSubaeraTablayout.setTabIndex(curZoneChannelPos, true);
mSubaeraTablayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
//not worked!
ToastUtil.showShortToast("position"+position);
}
@Override public void onPageSelected(int position) {
ToastUtil.showShortToast("position"+position);
}
@Override public void onPageScrollStateChanged(int state) {
ToastUtil.showShortToast("position"+state);
}
});`
it does not scroll when attached more TABS
In my xml file it says
Rendering problem
Asset not found : null
what should i do?
during runtime it logcats this exception
08-07 01:49:38.304 25153-25153/? W/System.err: java.lang.NullPointerException
08-07 01:49:38.304 25153-25153/? W/System.err: at android.graphics.FontFamily.nAddFontFromAsset(Native Method)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.graphics.FontFamily.addFontFromAsset(FontFamily.java:70)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.graphics.Typeface.createFromAsset(Typeface.java:185)
08-07 01:49:38.304 25153-25153/? W/System.err: at com.gigamole.navigationtabstrip.NavigationTabStrip.setTypeface(NavigationTabStrip.java:343)
08-07 01:49:38.304 25153-25153/? W/System.err: at com.gigamole.navigationtabstrip.NavigationTabStrip.(NavigationTabStrip.java:189)
08-07 01:49:38.304 25153-25153/? W/System.err: at com.gigamole.navigationtabstrip.NavigationTabStrip.(NavigationTabStrip.java:156)
08-07 01:49:38.304 25153-25153/? W/System.err: at java.lang.reflect.Constructor.newInstance(Native Method)
08-07 01:49:38.304 25153-25153/? W/System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.view.LayoutInflater.createView(LayoutInflater.java:611)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:418)
08-07 01:49:38.304 25153-25153/? W/System.err: at com.geeky.adarsh.moviescollection.Fragments.MainFragment.onCreateView(MainFragment.java:72)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:619)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1239)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.app.Activity.performStart(Activity.java:6057)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.app.ActivityThread.access$800(ActivityThread.java:154)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.os.Looper.loop(Looper.java:135)
08-07 01:49:38.304 25153-25153/? W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5276)
08-07 01:49:38.304 25153-25153/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
08-07 01:49:38.304 25153-25153/? W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
08-07 01:49:38.304 25153-25153/? W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911)
08-07 01:49:38.304 25153-25153/? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
its bug and no change when i set 0 or 1 for start tab can someone help me?
my page change listener is not working
internal class MyPageChangeListener : Java.Lang.Object, ViewPager.IOnPageChangeListener
{
public MyPageChangeListener(MainActivity activity)
{
this.activim = activity;
Toast.MakeText(activim, "Tammadır", ToastLength.Long).Show();
System.Diagnostics.Debug.WriteLine("sadgasg");
}
public MainActivity activim;
public void OnPageScrolled(int position, float positionOffset, int positionOffsetPixels)
{
Toast.MakeText(activim, "Tammadır", ToastLength.Long).Show();
System.Diagnostics.Debug.WriteLine("OnPageSelected" + " " + position);
}
public void OnPageScrollStateChanged(int position)
{
Toast.MakeText(activim, "Tammadır", ToastLength.Long).Show();
System.Diagnostics.Debug.WriteLine("OnPageSelected" + " " + position);
}
public void OnPageSelected(int position)
{
Toast.MakeText(activim, "Tammadır", ToastLength.Long).Show();
System.Diagnostics.Debug.WriteLine("OnPageSelected" + " " + position);
}
}
I imported the library by using Gralde Maven Central. I got no problem when I sync the projet and when I build the app but when I run it on my second activity (where the NavigationTabStrip is used) it crashes.
Here is the stacktrace :
06-23 21:38:27.792 29422-29422/com.linkpulsion.nethernalvibes E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.linkpulsion.nethernalvibes, PID: 29422
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.linkpulsion.nethernalvibes/com.linkpulsion.nethernalvibes.Player}: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class com.gigamole.library.NavigationTabStrip
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class com.gigamole.library.NavigationTabStrip
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.linkpulsion.nethernalvibes.Player.onCreate(Player.java:29)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class com.gigamole.library.NavigationTabStrip
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.linkpulsion.nethernalvibes.Player.onCreate(Player.java:29)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.gigamole.library.NavigationTabStrip" on path: DexPathList[[zip file "/data/app/com.linkpulsion.nethernalvibes-1/base.apk"],nativeLibraryDirectories=[/data/app/com.linkpulsion.nethernalvibes-1/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:595)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.linkpulsion.nethernalvibes.Player.onCreate(Player.java:29)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Suppressed: java.lang.ClassNotFoundException: Didn't find class "com.gigamole.library.NavigationTabStrip" on path: DexPathList[[dex file "/data/data/com.linkpulsion.nethernalvibes/files/instant-run/dex/slice-support-annotations-23.4.0_a6bb2a5bb9a40e4d6f6829e6518129a51f2ebb3b-classes.dex", dex file "/data/data/com.linkpulsion.nethernalvibes/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.linkpulsion.nethernalvibes/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.linkpulsion.nethernalvibes/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.linkpulsion.nethernalvibes/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.linkpulsion.nethernalvibes/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.linkpulsion.nethernalvibes/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.linkpulsion.nethernalvibes/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.linkpulsion.nethernalvibes
06-23 21:38:27.792 29422-29422/com.linkpulsion.nethernalvibes D/Error: ERR: exClass=java.lang.ClassNotFoundException
06-23 21:38:27.792 29422-29422/com.linkpulsion.nethernalvibes D/Error: ERR: exMsg=Didn't find class "com.gigamole.library.NavigationTabStrip" on path: DexPathList[[zip file "/data/app/com.linkpulsion.nethernalvibes-1/base.apk"],nativeLibraryDirectories=[/data/app/com.linkpulsion.nethernalvibes-1/lib/arm64, /vendor/lib64, /system/lib64]]
06-23 21:38:27.792 29422-29422/com.linkpulsion.nethernalvibes D/Error: ERR: file=BaseDexClassLoader.java
06-23 21:38:27.792 29422-29422/com.linkpulsion.nethernalvibes D/Error: ERR: class=dalvik.system.BaseDexClassLoader
06-23 21:38:27.792 29422-29422/com.linkpulsion.nethernalvibes D/Error: ERR: method=findClass line=56
I tried to add icons instead of text but i am unable to do so, there is no any method.
I also tried this Link.
Even if you pass it in
app:nts_titles="@array/titles"
and pass the drawable in it does not work.
Please help me to add icons in tabs.
I have potentially long titles, and titles draw over each other , anything i'm missing?
Hi! Please, can you show an example of setOnTabStripSelectedIndexListener?
Unfortunately, I can't understand how it works :(
Font asset not found fonts/drugs.otf
at com.gigamole.navigationtabstrip.NavigationTabStrip.setTypeface
Calling setTabIndex
on the NavStrip is causing the app to crash with the following report
app:theme is now deprecated. Please move to using android:theme instead.
I am using Android Data Binding for View Reference in Activity
Looks like you don't use it, why do you compile it?
I am using the library in my project but unable to change the pointer size in the between the tab strip.
Please let me know how can I do that
Hi , Thank you for this beutiful library but , when i try to add it to my project Android Studio Can't find it What shoud i do ?
Is it possible to make the strip align the width of the selected text?
i want to use bitmap...
I want reduce strip(line) width size!
Is that possible?
Hi, i was looked the closed issues and saw Fragment implementing and i have a problem with this too. It's not clear to how to catch and how to change Fragments with your library. i have a 2 Fragments and i want to implement this with ViewPager but i can not. Please give an example for this. Thanks. By the way i 'm implementing your library with these codes:
`
mViewPager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return 2;
}
@Override
public boolean isViewFromObject(final View view, final Object object) {
return view.equals(object);
}
@Override
public void destroyItem(final View container, final int position, final Object object) {
((ViewPager) container).removeView((View) object);
}
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final View view = new View(getBaseContext());
container.addView(view);
return view;
}
});
mCenterNavigationTabStrip.setViewPager(mViewPager, 1);
`
unfortunately i got following error
Fatal Exception: java.lang.ArrayIndexOutOfBoundsExceptionlength=5; index=-1 Raw Text
--
| com.gigamole.navigationtabstrip.NavigationTabStrip.onPageScrollStateChanged (NavigationTabStrip.java:747)
| android.support.v4.view.ViewPager.dispatchOnScrollStateChanged (ViewPager.java:1956)
| com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1200)
i can't reproduce it and saw this error in the fabric
The application contains 3 tabs - Home, About and FAQ. Within About tab, I've 2 more tabs namely - User details and Privacy Policy. Each of these will load a fragment
into viewpager
. Below is relevant code I am having now.
HomeActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Intent intentData = getIntent();
initUI();
}
private void initUI() {
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFrag(new HomeFragment(), "Home");
adapter.addFrag(new AboutFragment(), "About");
adapter.addFrag(new FAQFragment(), "FAQ");
viewPager.setAdapter(adapter);
final NavigationTabStrip navigationTabStrip = (NavigationTabStrip) findViewById(R.id.nts_bottom);
navigationTabStrip.setViewPager(viewPager, 0);
}
AboutFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view=inflater.inflate(R.layout.fragment_about, container, false);
new Thread(new Runnable() {
@Override
public void run() {
initUI(view);
}
}).start();
return view;
}
private void initUI(View view) {
final ViewPager viewPager = (ViewPager) view.findViewById(R.id.about_horizontal_tab);
ViewPagerAdapter adapter = new ViewPagerAdapter(getActivity().getSupportFragmentManager());
adapter.addFrag(new UserDetailsFragment(), "User Details");
adapter.addFrag(new PrivacyPolicyFragment(), "Privacy Policy");
viewPager.setAdapter(adapter);
final NavigationTabStrip navigationTabStrip = (NavigationTabStrip) view.findViewById(R.id.nts_top);
navigationTabStrip.setViewPager(viewPager, 0);
}
ViewPagerAdapter.java
public class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFrag(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}
But contents within About tab's, User Details
and Privacy Policy
never loads even though, when debugged, it hits the respective fragment's onCreateView
method. Similarly, when I navigate to Privacy Policy
tab it gets stuck there and doesn't navigate back to User Details
tab on click.
How could I possibly solve this issue? Is it supported to have nested tabs in android?
How to set tabs by start from right to left ?!
How to ensure that the first time onEndTabSelected method will be triggered
Sup everyone!
Is this possible to make inactive dots visible?
Thank you!
I have many tabs on the strip, the animation force to load every tab when moving, need to disable animation and jump directory to target tab.
Hi, Is there any way to make the tab scrollable? if the titles are too long they gonna be overlapping each other which is not readable, but if the tab layout would be scrollable that would handle it.
At the moment this library can only be used if you have very short titles or minimal pages like 4.
I can't find any settings to set tab label in lower-case ...
I can not setup app:tabMode="scrollable" like tabLayout, Please?
As the title says. Using NavigationTabBar#deselect when onStartTabSelected gets called.
It will not throw the error in onEndTabSelected. The stacktrace said the error came from line 868 and 877 in NavigationTabBar.java
I dug around a bit in your code and adding a && mIndex != INVALID_INDEX
to the if statement, above the two mentioned lines, fixed the issue.
how to add scroll for more tabs ?! I have many tabs and I cant show it without scroll on screen.
Hi! Thanks for providing such a good library!
I have a question: is there possibility to add new line to the TabTitle? I set text with "\n" but it drawing like single line.
Thanks in advance!
When I change of fragment, always return position 0.
mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return mHistoryFragment;
case 1:
return mPostFragment;
default:
return null;
}
}
@Override
public int getCount() {
return 2;
}
});
mViewPager.setPageMargin(8); // TODO Convert 'px' to 'dp'
mViewPager.setPageMarginDrawable(R.color.accent);
mTabsAction.setViewPager(mViewPager);
mTabsAction.setTitles(getString(R.string.button_new_history), getString(R.string.button_new_post));
//mTabsAction.setTabIndex(0, true);
mTabsAction.setStripColor(getResources().getColor(R.color.accent));
mTabsAction.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
validateButton();
switch (position) {
case 0:
TAB = HISTORY;
validateDraft(Constants.HISTORY);
break;
case 1:
TAB = POST;
validateDraft(Constants.POST);
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mTabsAction.setOnTabStripSelectedIndexListener(new NavigationTabStrip.OnTabStripSelectedIndexListener() {
@Override
public void onStartTabSelected(String title, int index) {
validateButton();
switch (index) {
case 0:
TAB = HISTORY;
validateDraft(Constants.HISTORY);
break;
case 1:
TAB = POST;
validateDraft(Constants.POST);
break;
}
}
@Override
public void onEndTabSelected(String title, int index) {
}
});
thanks
Is it possible to put NavigationTabStrip inside HorizontalScrollView?
I tried to do this, but NavigationTabStrip is not displayed.
`<HorizontalScrollView
android:id="@+id/a"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.gigamole.navigationtabstrip.NavigationTabStrip
android:layout_width="50dp"
android:layout_height="50dp"
app:nts_active_color="@color/text_color_nav"
app:nts_animation_duration="200"
app:nts_color="@color/statusbar_color"
app:nts_corners_radius="1.5dp"
app:nts_factor="1"
app:nts_gravity="bottom"
app:nts_inactive_color="#c4c4c4"
app:nts_size="15sp"
app:nts_titles="@array/coils_count"
app:nts_type="line"
app:nts_weight="2dp" />
</HorizontalScrollView>`
I need to make a scrollable NavigationTabStrip with many elements. Is it possible to implement it?
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.ListFragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.Toast;
import com.gigamole.navigationtabstrip.NavigationTabStrip;
public class MainActivity extends AppCompatActivity {
private NavigationTabStrip mCenterNavigationTabStrip;
private FrameLayout frameLayout;
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
mCenterNavigationTabStrip = (NavigationTabStrip) findViewById(R.id.nts_center);
mViewPager = (ViewPager) findViewById(R.id.vp);
toolbar.setTitleTextColor(G.context.getResources().getColor(R.color.item));
frameLayout = (FrameLayout) findViewById(R.id.farmlayout);
setUI();
mCenterNavigationTabStrip.setViewPager(mViewPager);
mCenterNavigationTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
// Toast.makeText(G.context, "positon =" + position, Toast.LENGTH_SHORT).show();
mViewPager.setCurrentItem(position);
// Toast.makeText(G.context, "positon =" + mViewPager.getCurrentItem(), Toast.LENGTH_SHORT).show();
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mCenterNavigationTabStrip.setOnTabStripSelectedIndexListener(new NavigationTabStrip.OnTabStripSelectedIndexListener() {
@Override
public void onStartTabSelected(String title, int index) {
mViewPager.setCurrentItem(index);
Toast.makeText(G.context, "viewpager =" + mViewPager.getCurrentItem() + "index " + index , Toast.LENGTH_SHORT).show();
}
@Override
public void onEndTabSelected(String title, int index) {
}
});
}
@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}
private void setUI() {
mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return new loginFragment();
case 1:
return new signupFragment();
default:
return null;
}
}
@Override
public int getCount() {
return 2;
}
});
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.