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

Support for RTL locales #48

Closed royale1223 closed 9 years ago

royale1223 commented 9 years ago

Right now adding android:supportsRtl="true" to the manifest causes STL to behave weirdly. Tab indicator orders and viewpager order is reversed but scroll gesture direction is not.

Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mapck" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/LightTheme"
        android:supportsRtl="true" >
    .......

STL setup

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(null);
    SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
    setupTabs(viewPagerTab);
    FragmentPagerItems pages = new FragmentPagerItems(this);
    pages.add("a" A.class));
    pages.add("b", B.class));
    pages.add("c", C.class));
    pages.add("d", D.class));
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(),
            pages);
    viewPager.addOnPageChangeListener(this);
    viewPager.setAdapter(adapter);
    viewPager.setOffscreenPageLimit(2);
    viewPagerTab.setViewPager(viewPager);

setUpTabs

private void setupTabs(SmartTabLayout layout) {
    final LayoutInflater inflater = LayoutInflater.from(layout.getContext());

    layout.setCustomTabView(new SmartTabLayout.TabProvider() {
        @Override
        public View createTabView(ViewGroup container, int position, PagerAdapter adapter) {
            ImageView icon = (ImageView) inflater.inflate(R.layout.custom_tab_icon, container, false);
            switch (position) {
                case 0:
                    icon.setImageResource(R.drawable.a);
                case 1:
                    icon.setImageResource(R.drawable.b);
                case 2:
                    icon.setImageResource(R.drawable.c);
                case 3:
                    icon.setImageResource(R.drawable.d);
                    break;
                default:
                    throw new IllegalStateException("Invalid position: " + position);
            }
            return icon;
        }
    });
}
ogaclejapan commented 9 years ago

Hi, @royale1223 Thank you for reporting.

It is a bug. Sorry, I did not test the RTL.

ogaclejapan commented 9 years ago

Hi, @royale1223

RTL support version was just released :+1:

amradel700 commented 8 years ago

@royale1223 Please if you solve the RTL problem , can you send me a sample.

royale1223 commented 7 years ago

Sorry, I'm not using this library any longer.

On Thu, Nov 3, 2016 at 1:09 PM, amradel700 notifications@github.com wrote:

@royale1223 https://github.com/royale1223 Please if you solve the RTL problem , can you send me a sample.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ogaclejapan/SmartTabLayout/issues/48#issuecomment-258079213, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMO3mRi_dcuzUUqHn5CsMLOzIYfSVkAks5q6Y_HgaJpZM4FY9dJ .

-- Dr. Binoy Babu, Kaimathuruthil, Puthenvelikkara, Eranakulam 683594 Mob : +91 9961 31 2801

drorGlucome commented 5 years ago

hey what about the RTL support? did you fix this issue?