Git Product home page Git Product logo

pagerslidingtabstrip's People

Contributors

antoniolg avatar astuetz avatar ataulm avatar austinschulz avatar bryant1410 avatar elliottsj avatar fawaad avatar gbero avatar guillermolechuga avatar heinrichreimer avatar henriquerocha avatar jcdom avatar jpardogo avatar jupiter avatar jwir3 avatar kernald avatar krschultz avatar lnikkila avatar luciofm avatar mpost avatar mstevens83 avatar no99gk avatar shusshu avatar vkeat660 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  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

pagerslidingtabstrip's Issues

Performance Issues

For some reason this implementation is very very laggy in comparison with original astuetz/PagerSlidingTabStrip. Following setup will reproduce the issue:

  1. Main activity layout is DrawerLayout with Fragments being loaded to the ViewPager's manager
  2. Add more than 5 pages to the pager
  3. Each fragment has ScrollView as the root element and couple more views inside (ex. create a simple View with 500dp height)

Swiping and scrolling loses frames, which is not the case when using original lib.

Middle Alignment (pstsPaddingMiddle="true") only shows first tab. Everything else is hidden

Only the first tab appears. I am able to scroll to all the other ones but they don't show up or scroll. There are no build errors of any kind. The following does appear in the preview box, however:

java.lang.NumberFormatException: Color value '/Users/charrondev/Dev/android-sdk/platforms/android-21/data/res/color/primary_text_dark.xml' must start with #
at com.android.layoutlib.bridge.impl.ResourceHelper.getColor(ResourceHelper.java:72)
at android.content.res.BridgeResources.getColor(BridgeResources.java:182)
at com.astuetz.PagerSlidingTabStrip.(PagerSlidingTabStrip.java:142)
at com.astuetz.PagerSlidingTabStrip.(PagerSlidingTabStrip.java:129)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:379)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:99)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:401)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:329)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:674)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:663)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:663)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:790)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:611)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1900(AndroidLayoutPreviewToolWindowManager.java:81)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:553)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:548)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)

This is on the latest Android SDK and build tools.

Add <type>aar</type> to support-v4 dependency declaration in library pom

The pom file of the om.jpardogo.materialtabstrip library (as published to Maven central: http://repo1.maven.org/maven2/com/jpardogo/materialtabstrip/library/1.0.6/library-1.0.6.pom) contains this dependency declaration

<dependency>
    <groupId>com.android.support</groupId>
    <artifactId>support-v4</artifactId>
    <version>21.0.2</version>
    <scope>compile</scope>
</dependency>

This causes a problem when a project which depends on the library is being built using maven (rather than gradle, which I assume doesn't have this problem).
Because recent versions of support-v4 are packaged as an aar file, rather than the default jar maven is unable to resolve the dependency:

Failure to find com.android.support:support-v4:jar:21.0.2

This is very easy to solve however, all it takes is adding the packaging type to the dependency declaration:

<dependency>
    <groupId>com.android.support</groupId>
    <artifactId>support-v4</artifactId>
    <version>21.0.2</version>
    <type>aar</type>
    <scope>compile</scope>
</dependency>

Please consider this for the next release to Maven central. Thanks!

Multiple tabs issue

I am having multiple tab layers. I don't know why this is happening.

This is how it looks
screenshot from 2015-01-25 22 35 45
screenshot from 2015-01-25 22 36 13

This is my code i am using
My Home Class
public class HomeClass extends Fragment {

private static final String ARG_POSITION = "position";

public static HomeClass newInstance(int position) {
    HomeClass f = new HomeClass();
    Bundle b = new Bundle();
    b.putInt(ARG_POSITION, position);
    f.setArguments(b);
    return f;
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_main, container, false);
    // Initialize the ViewPager and set an adapter
    ViewPager pager = (ViewPager) view.findViewById(R.id.pager);

    pager.setAdapter(new PagerAdapter(getActivity().getSupportFragmentManager()));

    // Bind the tabs to the ViewPager
    PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
    tabs.setViewPager(pager);

    return view;
}

}

My PagerAdapter Class
public class PagerAdapter extends FragmentPagerAdapter {
private final String[] TITLES = {"TAB1", "TAB2", "TAB3"};

public PagerAdapter(FragmentManager fm) {
    super(fm);
}

@Override
public Fragment getItem(int position) {
    return HomeClass.newInstance(position);
}

@Override
public CharSequence getPageTitle(int position) {
    return TITLES[position];
}

@Override
public int getCount() {
    return TITLES.length;
}

}

My Layout XML file

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
   <com.astuetz.PagerSlidingTabStrip
      android:id="@+id/tabs"
      android:layout_width="match_parent"
      android:layout_height="?attr/actionBarSize"
      android:background="?attr/colorPrimary"
      android:fillViewport="false" />
   <android.support.v4.view.ViewPager
      android:id="@+id/pager"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
       android:layout_below="@+id/tabs" />
  </RelativeLayout>

Update Maven Central

Would you mind putting the latest build up on Maven? It looks like it hasn't been updated since November.

Thanks!

missing attribute

Is there an attribute which will allow me to have indicator not on bottom of the PagerSlidingTabStrip layout but instead it will have some kind of padding from botom ? I mean like it will float beneath the text like this :

ICON
TEXT
SPACE
INDICATOR
SPACE

Sorry for bad issue, but I can't express myself properly. It could look like this : https://imgur.com/haT6OeA

Indicating press state on not activated tab

Hello!

In google play app when you press tab that is not activated its text color becomes like in activated tab. Could you make the same behavior in your library?

Thanks for your work!

Setting app:pstsTabBackground hides indicators

It appears that setting app:pstsTabBackground causes the indicators at the bottom to become hidden. I can see it being animated from one to the other, but it is clearly underneath the rest of the tab in the view stack.

Doesn't show up with auto hide Acton bar

Hi,

I'm glad that this library is there to ease our life. In my app I'm using a feature due to which the hides the action bar when scrolled down.
Due to this the view pager is not been shown, if it does then it is shown below list view. I've tried adding padding but no success.
BTW you can check out Android Observable Scroll View library to know about hiding action bar on scroll.
Can you help me this issue?

Thanks in advance

The tabs do not scale correctly when using pstsShouldExpand="true" when rotating the device

Hi,

first of all, a really great project!

if I use pstsShouldExpand="true" with two tabs and rotate my Nexus 7 from portrait to landscape and then back again, then the tabs still have the width from the landscape layout, i.e the first tab covers most of the width in portrait.

it worked correctly in v1.0.5 and the changed behavior was in the commit: "Fix tabsContainer always have to be as wide as the parent".

if i revert the following lines back in that commit:

From:
@OverRide
protected void onLayout(boolean changed, int l, int t, int r, int b) {
//Make sure tabContainer is bigger than the HorizontalScrollView to be able to scroll
tabsContainer.setMinimumWidth(getWidth());
//Clipping padding to false to see the tabs while we pass them swiping
setClipToPadding(false);

To:
@OverRide
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (isPaddingMiddle) {
//Make sure tabContainer is bigger than the HorizontalScrollView to be able to scroll
tabsContainer.setMinimumWidth(getWidth());
//Clipping padding to false to see the tabs while we pass them swiping
setClipToPadding(false);
}

i.e. add the condition back with isPaddingMiddle then that tabs works correctly with pstsShouldExpand="true".

Regards/
Lars

Crash on android version below Jelly Bean

private OnGlobalLayoutListener firstTabGlobalLayoutListener = new OnGlobalLayoutListener() {

        @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
        @Override
        public void onGlobalLayout() {
            View view = tabsContainer.getChildAt(0);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            } else {
                view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }

            if (isPaddingMiddle) {
                int mHalfWidthFirstTab = view.getWidth() / 2;
                paddingLeft = paddingRight = getWidth() / 2 - mHalfWidthFirstTab;
            }
            setPadding(paddingLeft, getPaddingTop(), paddingRight, getPaddingBottom());
            if (scrollOffset == 0) scrollOffset = getWidth() / 2 - paddingLeft;
        }
    };

No such method removeOnGlobalLayoutListener, should be removeGlobalOnLayoutListener

Please fix it

Weird behavior on device rotation

The scroll amount seems cached from the pre-rotated amount, and not recomputed. This leads to "snapping" when you scroll through the viewpager or tap a tab after rotating the device.

Google IO's SlidingTabLayout does not exhibit this behavior.

How to remove line between Toolbar and TabStrip?

Image

How do I remove the grey shadow/line as shown above?

My layout is as follows:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" app:theme="@style/ThemeOverlay.AppCompat.ActionBar" android:background="?attr/colorPrimaryDark"/>

<com.astuetz.PagerSlidingTabStrip android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="40dp" android:elevation="4dp" android:background="?attr/colorPrimary" android:textColor="@color/white" app:pstsIndicatorColor="@color/white" app:pstsShouldExpand="true" />

BUG, switch from this(as a fragment) to a fragment, crashed!

This happens when I set no adapter to mRecyclerView. I get this but running well:

E/RecyclerView﹕ No adapter attached; skipping layout

Here is the exception when detaching:

java.lang.IllegalStateException: Observer com.astuetz.PagerSlidingTabStrip$PagerAdapterObserver@419b0668 was not registered.
            at android.database.Observable.unregisterObserver(Observable.java:64)
            at android.support.v4.view.PagerAdapter.unregisterDataSetObserver(PagerAdapter.java:294)
            at com.astuetz.PagerSlidingTabStrip.onDetachedFromWindow(PagerSlidingTabStrip.java:552)
            at android.view.View.dispatchDetachedFromWindow(View.java:9848)
            at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2342)
            at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2340)
            at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2340)
            at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3671)
            at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3651)
            at android.view.ViewGroup.removeView(ViewGroup.java:3599)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1045)
            at android.support.v4.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1223)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:696)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
            at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:454)
            at android.os.Handler.handleCallback(Handler.java:605)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4503)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
            at dalvik.system.NativeStart.main(Native Method)

Style from `CustomTabProvider` is overwritten

I am trying to have a single tab with a different text color. For this, I implement CustomTabProvider and call TextView.setTextColor().

However, this change is overwritten by updateTabStyles().

I suggest to change the code so, that the tab style is only applied by the library if CustomTabProvider is not implemented. (I will probably make a pull request for this myself).

Problem maintaining tab highlight upon orientation change

I'm experiencing a slightly strange issue, and for whatever reason it only occurs on my Nexus 5, but not on my Nexus 9. It's kind of hard to describe, so I'll start with some screenshots.

This is what the application looks like to begin with:

device-2014-12-01-001835

As you can see, there are a number of tabs, starting with "All movies", "Favorites" and "New releases". Whenever I swipe to a tab that's not the first tab, it messes up the highlighting upon orientation change.

Here's an example, starting with the "New releases" tab selected:

device-2014-12-01-001919

Rotate the device, and this is what it looks like:

device-2014-12-01-001944

As you can see, it doesn't look right. Here's a screenshot of what it looks like when I scroll the tabs a bit:

device-2014-12-01-001956

Once I start scrolling the actual content, it fixes itself immediately:

device-2014-12-01-002006

Incorrect indicator positioning on custom fragment width

I'm overriding the FragmentAdapter#getPageWidth (for tablets) in my app.
It looks like because the last tab is smaller than the full device width (thereby not starting from the farthest left), the indicator assumes the pager is still in transit and remains at a few pixels before its actual destination.

I've reproduced this in the sample by overriding getPageWidth in MyPagerAdapter

public class MyPagerAdapter extends FragmentPagerAdapter {

        // . . .

        @Override
        public float getPageWidth(int position) {
            return 0.7F;
        }
    }

OUTPUT
This is correct
screenshot_2015-01-26-10-43-04

Last tab - indicator doesn't reach its final destination
screenshot_2015-01-26-10-43-12

Play Store like middle padding

How would I recreate the Play Store-like middle padding? By this I only mean that the tab is only in the center of the screen when it is one of the middle tabs. If it is one of the outer left or right tabs, it is shown as it. This is a video showing the Play Store behaviour: http://youtu.be/Chwce6QjYI0

This lib vs. Android's sample implementation

Hello everyone,

I found this library while working on my Lollipop-only app and I added it to my project. But then I stumbled upon this Android sample project http://developer.android.com/samples/SlidingTabsBasic/index.html, and I don't really know what's the difference between them.

What I noticed at first sight is that the sample implementation of tab strip has the ripple effect on click, while this library doesn't. But, this library picked up the colors from my theme automatically, while using the sample would require changing the colors myself (though that won't be a hindrance).

So, what do you suggest?

1.09 update - broke text left/right padding. Cannot have a tabStrip less than full width that does not scroll now

I have a tabstrip with 3 options. I would like to have some left padding. In 1.08, if you added an equal amount of right padding, the tab strip would not be scrollable if it didn't need to be. In 1.09, it scrolls even with the same amount of left and right padding.

<com.astuetz.PagerSlidingTabStrip
        android:id="@+id/slidingtabs"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:textColor="@android:color/white"
        app:pstsTextAlpha="127"
        app:pstsIndicatorColor="@android:color/white"
        app:pstsTextColorSelected="@android:color/white"
        android:elevation="@dimen/default_appbar_elevation"
    />

screenshot_2015-02-25-20-07-28
screenshot_2015-02-25-20-07-36

Changing the default Tab

how can i change the first tab when the program starts?
by default is the left tab but i want to be the right tab.

Dividers are not being rendered.

<com.astuetz.PagerSlidingTabStrip
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorTabBackground"
    android:foreground="?android:attr/windowContentOverlay"
    android:textColor="?attr/colorTabText"
    android:textSize="13sp"
    app:pstsIndicatorColor="?attr/colorTabIndicator"
    app:pstsIndicatorHeight="5dp"
    app:pstsUnderlineColor="?attr/colorTabBottomDivider"
    app:pstsUnderlineHeight="1dp"
    app:pstsDividerColor="#FF0000"
    app:pstsShouldExpand="true"/>

pstsPaddingMiddle does not center align longer elements.

I don't know if this is related to the previous issue at all, but in the example here: https://github.com/Charrondev/BugTestPagerSlidingTab
If you scroll over to the elements with longer titles, they do not center align, rather they align the left edge of the scroller to the same spot it would if it were a shorter title. Not a showstopper by any means, but its there.

On a side note, you maintain some very nice libraries. Do you happen to take donations?

How to set different colors for selected tab and unselected?

At this momment I chachive different colors by overriding following in library:

 private void notSelected(View tab) {
        TextView title = (TextView) tab.findViewById(R.id.tab_title);
        if (title != null) {
            title.setTypeface(tabTypeface, tabTypefaceStyle);
            title.setTextColor(Color.parseColor("#40000000"));
//            ViewCompat.setAlpha(title, tabTextAlpha);
        }
    }

    private void selected(View tab) {
        TextView title = (TextView) tab.findViewById(R.id.tab_title);
        if (title != null) {
            title.setTypeface(tabTypeface, tabTypefaceSelectedStyle);
            title.setTextColor(getTextColor());
//            ViewCompat.setAlpha(title, tabTextSelectedAlpha);
        }
    }
 private void updateTabStyles() {
        for (int i = 0; i < tabCount; i++) {
            View v = tabsContainer.getChildAt(i);
            v.setBackgroundResource(tabBackgroundResId);
            TextView tab_title = (TextView) v.findViewById(R.id.tab_title);

            if (tab_title != null) {
                tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
                tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
                if (tabTextColor != null) {
                    tab_title.setTextColor(tabTextColor);
                }
                // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
                // pre-ICS-build
                if (textAllCaps) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                        tab_title.setAllCaps(true);
                    } else {
                        tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                    }
                }
                if(pager.getCurrentItem()==i){
                    selected(v);
                }else {
                    notSelected(v);
                }

            }

        }
    }

I say that textColo is colorstate object, but i was not managed make it work

crashes when close app

12-11 10:25:22.940 10693-10693/com.alex.photolessons E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.alex.photolessons, PID: 10693
java.lang.IllegalStateException: Observer com.astuetz.PagerSlidingTabStrip$PagerAdapterObserver@3b31bb43 was not registered.
at android.database.Observable.unregisterObserver(Observable.java:69)
at android.support.v4.view.PagerAdapter.unregisterDataSetObserver(PagerAdapter.java:294)
at com.astuetz.PagerSlidingTabStrip.onDetachedFromWindow(PagerSlidingTabStrip.java:533)
at android.view.View.dispatchDetachedFromWindow(View.java:13441)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2837)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2834)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2834)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2834)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2834)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2834)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2834)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2834)
at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2889)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5390)
at android.view.ViewRootImpl.die(ViewRootImpl.java:5367)
at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:359)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:314)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3707)
at android.app.ActivityThread.access$1400(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

1.09 update - broke text alpha

The text alpha is not being set correctly. I was not using app:pstsTextAlpha with 1.08, and I noticed that I need to. The below did not work to fix it. The pstsTextAlpha should set the alpha on the android:textColor value right?
screenshot_2015-02-25-20-07-28

<com.astuetz.PagerSlidingTabStrip
        android:id="@+id/slidingtabs"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:textColor="@android:color/white"
        app:pstsTextAlpha="127"
        app:pstsIndicatorColor="@android:color/white"
        app:pstsTextColorSelected="@android:color/white"
        android:elevation="@dimen/default_appbar_elevation"
    />

View does not use its own textColorPrimary value

If I specify the textColorPrimary as an attribute of the view (or if I specify it in a theme via the style attribute), the value is ignored and textColorPrimary from the parent theme is used instead.

<com.astuetz.PagerSlidingTabStrip
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="?android:actionBarSize"
        android:textColorPrimary="@android:color/white"
        app:pstsShouldExpand="true" />

(i.e. the @android:color/white value is ignored)

I've tried breaking on this line (PagerSlidingTabStrip.java#L156) to see if obtainStyledAttributes is returning the right attributes:

While paused, running the expression

context.obtainStyledAttributes(attrs, new int[] {android.R.attr.textColorPrimary}).getString(0)

gives me the correct value of "#ffffffff". But running

context.obtainStyledAttributes(attrs, ATTRS).getString(TEXT_COLOR_PRIMARY)

gives me the incorrect value of "#ff212121" (from the parent theme).

Then, stepping past L#159, int textPrimaryColor has that same incorrect value (converted to an int): -14606047 (== 0xFF212121)


I'm wondering if this is an Android issue because

context.obtainStyledAttributes(attrs, new int[] {android.R.attr.textColorPrimary}).getString(0)

should really be the same value as

context.obtainStyledAttributes(attrs, ATTRS).getString(TEXT_COLOR_PRIMARY)

java.lang.NoSuchFieldError: com.astuetz.pagerslidingtabstrip.R$id.tab_title

could you please explain to me this error? This doesn't happen when I add an textView with tab_title id, docs don't mention to add it although, and still I get other issue, the view is blank...

java.lang.NoSuchFieldError: com.astuetz.pagerslidingtabstrip.R$id.tab_title
            at com.astuetz.PagerSlidingTabStrip.addTab(PagerSlidingTabStrip.java:279)
            at com.astuetz.PagerSlidingTabStrip.notifyDataSetChanged(PagerSlidingTabStrip.java:253)
            at com.astuetz.PagerSlidingTabStrip.setViewPager(PagerSlidingTabStrip.java:236)

Crashing when change rotation with selected tab( not first tab ).

Caused by: java.lang.NullPointerException
        at com.astuetz.PagerSlidingTabStrip.notSelected(PagerSlidingTabStrip.java:295)
        at com.astuetz.PagerSlidingTabStrip.onRestoreInstanceState(PagerSlidingTabStrip.java:643)
        at android.view.View.dispatchRestoreInstanceState(View.java:12799)

setCurrentItem on viewPager not working

When I create my view, I want that viewPager move to some pager (eg pager number 1).
ViewPager move to that pager and PSTS update the states of every tab, but doesn't move the scroll to the correct position.
I have changed your example to be like mine and it doesn't work.
The changes that I have done are the following:

MainActivity.java:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
        setSupportActionBar(toolbar);
        // create our manager instance after the content view is set
        mTintManager = new SystemBarTintManager(this);
        // enable status bar tint
        mTintManager.setStatusBarTintEnabled(true);
        adapter = new MyPagerAdapter(getSupportFragmentManager());
        pager.setAdapter(adapter);
        tabs.setViewPager(pager);
        final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources()
                .getDisplayMetrics());
        pager.setPageMargin(pageMargin);
        changeColor(getResources().getColor(R.color.green));
     pager.setCurrentItem(1);
    }

activity_main.xml:

<com.astuetz.PagerSlidingTabStrip
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:pstsShouldExpand="true" />

screenshot_2015-01-24-13-26-51

Icon Tabs

What happened to the icon tabs from the astuetz library? Icon support would be much appreciated, thanks.

No padding around text.

There is no padding around text of tabs with version 4.0.4 on a tablet. It works on my Nexus 5 on Lollipop.
Here is my XML extract :
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:textColor="@color/white"
app:pstsIndicatorColor="@color/white"
app:pstsTabBackground="?attr/selectableItemBackground"/>

https://github.com/StephaneBg/ScoreItProject/blob/master/ScoreIt/src/main/res/layout-sw600dp/activity_about.xml

screenshot_2014-11-25-18-20-55

screenshot_2014-11-25-18-24-56 1

Middle alignment not working when no tabs are added yet

I am trying to use pstsPaddingMiddle="true" with a FragmentStatePagerAdapter. This adapter does not have any items when the fragment is first created and my app crashes with the following error:

java.lang.NullPointerException
            at com.astuetz.PagerSlidingTabStrip.onLayout(PagerSlidingTabStrip.java:419)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:543)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:887)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:502)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14841)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1986)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1743)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5603)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
            at android.view.Choreographer.doCallbacks(Choreographer.java:574)
            at android.view.Choreographer.doFrame(Choreographer.java:544)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)```

The error points to https://github.com/jpardogo/PagerSlidingTabStrip/blob/master/library/src/com/astuetz/PagerSlidingTabStrip.java#L419 where the library assumes that there are always tabs, which is not true for my fragment.

Also, could issue #15 be reopened, as when I add a tab at the beginning to circumvent this error, it is still unusable. It looks like this, even though there are 3 tabs:
![image](https://cloud.githubusercontent.com/assets/1112623/5060983/c62222a2-6d7c-11e4-9437-fa8f30103448.png)
When moving to another tab, the new tab is not even shown.

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.