ogaclejapan / SmartTabLayout

A custom ViewPager title strip which gives continuous feedback to the user when scrolling
Apache License 2.0
7.09k stars 1.34k forks source link

When using the stl_indicatorAlwaysInCenter="true", do not scroll position is set in the onCreate #54

Closed ogaclejapan closed 9 years ago

ogaclejapan commented 9 years ago

The problem is easily reproducible with the test case.


<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  >

  <android.support.v4.view.ViewPager
    android:id="@id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

  <LinearLayout
    android:id="@+id/header"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/primary"
    >

    <android.support.v7.widget.Toolbar
      android:id="@id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:minHeight="?attr/actionBarSize"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
      >

    </android.support.v7.widget.Toolbar>

    <com.ogaclejapan.smarttablayout.SmartTabLayout
      android:id="@id/viewpagertab"
      android:layout_width="match_parent"
      android:layout_height="@dimen/tab_height"
      android:paddingBottom="4dp"
      app:stl_defaultTabTextColor="@color/white"
      app:stl_defaultTabTextMinWidth="120dp"
      app:stl_indicatorAlwaysInCenter="true"
      app:stl_indicatorColor="@color/accent"
      app:stl_indicatorCornerRadius="1.5dp"
      app:stl_indicatorInterpolation="smart"
      app:stl_indicatorThickness="3dp"
      app:stl_underlineColor="@color/transparent"
      />

  </LinearLayout>

</RelativeLayout>

  protected void onCreate(Bundle savedInstanceState) {

    ....

    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
        getSupportFragmentManager(), pages);

    viewPager.setAdapter(adapter);
    viewPagerTab.setViewPager(viewPager);

    viewPager.setCurrentItem(3);
  }
ogaclejapan commented 9 years ago

1.2.3 has been released.