GithubHelp home page GithubHelp logo

pizza / materialtabs Goto Github PK

View Code? Open in Web Editor NEW
233.0 233.0 38.0 28.4 MB

Easy-to-integrate tab bar with ripple effect for Android that completely respects Material Design for API 9+

License: MIT License

Java 100.00%

materialtabs's People

Contributors

antoniolg avatar astuetz avatar ataulm avatar austinschulz avatar elliottsj avatar guillermolechuga avatar henriquerocha avatar jpardogo avatar jupiter avatar kernald avatar krschultz avatar luciofm avatar mstevens83 avatar no99gk avatar pizza avatar shusshu avatar xdragonz avatar yolapop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

materialtabs's Issues

Question about TabChangeEvent

Is there an Tab Change event either the tab has been changed by code (setCurrentItem) or it has been scrolled/clicked?
It would be VERY VERY useful!

Sometimes the tab tile is not showing up correctly

I've tried the demo app and I've found an issue that prevents me from using the library(for the moment).

The tab tile for "item two" it's partially shown, even when it's selected. On the phone(nexus 5) it's even worse, because it's showing only "two" instead of the full title "item two".

This can be also seen in the demo gif
sample

I understand that the margins can show a glimpse of what's next, but we need to have at least the activated one that will show the full title text, in order to know the current tab.

Colors not working

Hi,
I'm using the following code snippet to declare my MaterialTabs in XML file:

<io.karim.MaterialTabs
android:id="@+id/material_tabs"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#FFFFFF"
android:textColor="#FF0000"
app:mtPaddingMiddle="false"
app:mtSameWeightTabs="true"
app:mtTextColorSelected="#00FF00"
/>

But I get only a white view, and its underlining indicator with default configuration.
But no text is displayed, and colors are not used when navigation through tabs.

Thank you in advance for your answer,
Regards.

New feature request

Hi, your MaterialTabs a good library. But it will be very nice if you implement next feature. When user scrolling tabs layout, during scroll viewpager must to be scrolled with the tabs and the tab's indicator will update its state too. Anyway, thank you.

Custom font

Hey, nice lib! It would be nice to have a parameter to change a custom font of textview in the tab.

active tabs

How to get which tab is active, and is it posible to set active 3 tabs.

Tab Item Padding Left and Right

hi, i want to reduce padding left and padding right in Tab Item, i use same weight, i still want same weight, but reduce padding left and padding right of tab items so, user will not be necessary to scroll tab item because i want fixed tab width. thank you.

how to implement a tab bar at the buttom to launch certain avtivity

hi i have tab bar and a view pager, i add another tab bar at the bottom and didnt connect the one and only viewpager to it since the first tab bar is using it and the second tab bar will take control of that and that is not my intention,i want to implement another tab bar at the bottom just to launch activities. can you tell me how to implement it via your library
thanks in advance

Compatibility issue for tabs color

i've integrated material tabs inside my project in Lollipop successfully , but when i'm testing on samsung galaxy note 2 ,android 4.4.2 , Material tab colors changes to device default tab color which is blue ? should i use any configuration for compatibility?

Better Support Reduction in Page Count

MaterialTabs depends on a ViewPager, which in turn depends on a PagerAdapter. If the PagerAdapter is modified to return a lower value from getCount() than it had returned earlier, and if the selected tab's position is beyond the new getCount(), when we call notifyDataSetChanged() to update the PagerAdapter, MaterialTabs crashes. Exactly where and how it crashes depends a bit on the timing of events, but one common spot is what is currently line 443, where from what I can tell tabsContainer.getChildAt(position) returns null.

This sample project can be used to illustrate the problem, though I presently have a workaround set up. Here, the ViewPager has either 3 or 10 pages, based on the state of a "Fixed" checkable overflow item. In onOptionsItemSelected(), I need to adjust things based on the current checked state of that MenuItem:

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId()==R.id.fixed) {
      item.setChecked(!item.isChecked());

      if (item.isChecked()) {
        if (pager.getCurrentItem()>2) {
          pager.setCurrentItem(2);
        }

        pager.postDelayed(new Runnable() {
          @Override
          public void run() {
            adapter.setPageCount(3);
            adapter.notifyDataSetChanged();
          }
        }, 100);
      }
      else {
        adapter.setPageCount(10);
        adapter.notifyDataSetChanged();
      }

      return(true);
    }

    return(super.onOptionsItemSelected(item));
  }

My original implementation just called setPageCount(3) on my SampleAdapter (subclass of FragmentPagerAdapter), then notifyDataSetChanged(). MaterialTabs crashed.

I then tried calling pager.setCurrentItem(2) before setPageCount(3), to try to switch the selected tab into the newly-safe range before reducing the page count. MaterialTabs crashed. Near as I can tell, it did not pick up the ViewPager current-item change before trying to deal with the page-count change.

I then tried moving the setPageCount(3) and notifyDataSetChanged() into a simple post() Runnable. That too tended to crash. Making it postDelayed(..., 100) gave me more reliable results. But any time we use post()/postDelayed() to try to postpone work until some other work gets done first, $DEITY kills a $CUTE_ANIMAL.

To reproduce the problem, roll back to my original implementation:

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId()==R.id.fixed) {
      item.setChecked(!item.isChecked());

      if (item.isChecked()) {
        adapter.setPageCount(3);
        adapter.notifyDataSetChanged();
      }
      else {
        adapter.setPageCount(10);
        adapter.notifyDataSetChanged();
      }

      return(true);
    }

    return(super.onOptionsItemSelected(item));
  }

Then:

  • Run the app, which starts off with three tabs
  • Click the "Fixed" checkable overflow item to uncheck it, at which point you will have ten tabs
  • Make "Editor #9" be the selected tab
  • Click the "Fixed" checkable overflow item to check it

You should get one variation of the crash, dying on line 334:

java.lang.NullPointerException
        at io.karim.MaterialTabs.scrollToChild(MaterialTabs.java:334)
        at io.karim.MaterialTabs.access$1200(MaterialTabs.java:50)
        at io.karim.MaterialTabs$3.onGlobalLayout(MaterialTabs.java:407)
        at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:808)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1768)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
        at android.view.Choreographer.doCallbacks(Choreographer.java:562)
        at android.view.Choreographer.doFrame(Choreographer.java:532)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
        at android.os.Handler.handleCallback(Handler.java:730)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5103)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)

Note that your existing code seems to handle expanding the number of pages just fine. It also works fine if the selected page is in the range of pages that is being retained (i.e., its position is inside the new getCount() value).

IMHO, asking us to move the selected page to a safe spot ourselves (via setCurrentItem()) is reasonable if you need that, but it really should not require us to then postDelayed() the actual page count change.

Thanks!

Failed to resolve MaterialTabs

Hi!

The demo looked impressive, I wanted to give it a try, but I got the following Gradle error:

Failed to resolve: com.github.pizza:MaterialTabs:2.0.3

As other projects from jitpack.io compile successfully I think that it must be an issue with MaterialTabs.

Thanks,
Robert

Sample is crashing.

Hi, I have just installed your sample from the play market. However, it's crashing after choosing the second configuration of tabs, i.e.

launched app->configuration selected -> open tabs ->back->configured again->opening results in crash.

Xperia Z1 compact, Lolipop 5.0.1

Unfortunately, I haven't so much time now, maybe I'll look deeper inside your sample later :)

Count in tab

Hey,

I am seeking to add the count in the tabs. Similar to what WhatsApp has done. Is there any straight way of doing it or is there any way to get the tab view and update it.

Thank you.

How to implement Tabs without viewPager?

I want the tabs but the fragments are replaced in the FrameLayout by FragmentTransaction.
but there is no method to add tabs programmatically. How can i do this?

Shadow below Tab indicator

When I have no tabs, the Actionbar, by default, drops a nice shadow. How to get a similar shadow for the MaterialTabs?

ICYMI, Google Play Store app tabs show a shadow and so does Whatsapp.

How to resize the icons.

@OverRide
public View getCustomTabView(ViewGroup parent, int position) {
ImageView imageView = new ImageView(MainActivity.this);
imageView.setImageResource(UNSELECTED_ICONS[position]);
return imageView;
}

    @Override
    public void onCustomTabViewSelected(View view, int position, boolean alreadySelected) {
        Log.i(TAG, "custom tab view selected with position = " + position);
        if (view instanceof ImageView) {
            ((ImageView) view).setImageResource(SELECTED_ICONS[position]);
        }
    }

    @Override
    public void onCustomTabViewUnselected(View view, int position, boolean alreadyUnselected) {
        Log.i(TAG, "custom tab view unselected with position = " + position);
        if (view instanceof ImageView) {
            ((ImageView) view).setImageResource(UNSELECTED_ICONS[position]);
        }

}

used this implements. But icon size are to big. Is there any way to set width and height of icon

Fragments displays wrong arraylists when switched between tabs

So, I have school timetable with 1 Tab activity with 1 fragment (5 tabs) which displays listview, populated with ArrayList rows through custom Adapter.
Problem occurs when switching content through Tabs. If I scroll out of screen (un-cache), make it offscreen and then scroll back to that Tab, I get correct ArrayList.

If needed, can provide code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.