3

I am facing the issue that I have a kind of padding in my SlidingTabLayout.

here is the screenshot enter image description here

so as you see, background comes out of the slider on the bottom. Recently, using pagertabstrip library, I nave not see that, but now I tried the new com.example.android.common.view.SlidingTabLayout its definitely there. How to remove this padding?

Thanks

and hiere is the xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.example.android.common.view.SlidingTabLayout
        android:id="@+id/lib_tabs"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/holo_green_light"
         />

    <android.support.v4.view.ViewPager
        android:id="@+id/lib_pager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
</LinearLayout>

style

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="windowActionBar">false</item>
        <item name="colorPrimary">@color/my_action_bar_color</item>
    </style>

    <style name="ToolBarStyle" parent="">
        <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
        <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>

    </style>

fragment

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.lib_tabs, null);

        mViewPager = (ViewPager) view.findViewById(R.id.lib_pager);
        mViewPager.setAdapter(new CustomPagerAdapter(this.getFragmentManager()));

        mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.lib_tabs);
        mSlidingTabLayout.setViewPager(mViewPager);

        return view;
    }

    public class CustomPagerAdapter extends FragmentPagerAdapter {

        private final String[] TITLES = {"Categories", "Home", "Top"};

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

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

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

        @Override
        public android.support.v4.app.Fragment getItem(int position) {
            return LibSimpleInstanceableFragment.newInstance();
        }
    }
user1908375
  • 1,069
  • 1
  • 14
  • 33

4 Answers4

6

This happens when distributeEvenly is true. Just comment

lp.width = 0;

in the populateTabStrip() method in the SlidingTabLayout.java class and your problem will be solved.

Unheilig
  • 16,196
  • 193
  • 68
  • 98
Afshin
  • 340
  • 4
  • 8
1

Change height to wrap_content:

<com.example.android.common.view.SlidingTabLayout
        android:id="@+id/lib_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/holo_green_light"
         />
Timofey Orischenko
  • 1,148
  • 1
  • 9
  • 12
0
  1. Find and open SlidingTabStrip.java (Must be under com/example/android/common/view/)
  2. Edit the following values as per your needs

    private static final int DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS = 0;
    private static final byte DEFAULT_BOTTOM_BORDER_COLOR_ALPHA = 0x26;

  3. You owe me a wine!

0

Remove minHeight on SlidingTabLayout

蔡国豪
  • 1
  • 1