一个小型库,可帮助更轻松地将 TabLayout 与 ViewPager 结合使用。
TabLayout with ViewPager more easily.TabLayout.MODE_FIXED and TabLayout.MODE_SCROLLABLE depends on total tab width.This library is published on Maven Central. Just add these lines to build.gradle.
dependencies {
implementation 'com.h6ah4i.android.tablayouthelper:tablayouthelper:1.0.0'
}NOTE
ViewPager viewPager = (ViewPager) findViewById(...);
TabLayout tabLayout = (TabLayout) findViewById(...);
PagerAdapter adapter = new XXXPagerAdapter();
viewPager.setAdapter(adapter);
// initialize the TabLayoutHelper instance
mTabLayoutHelper = new TabLayoutHelper(tabLayout, viewPager);
// [Optional] enables auto tab mode adjustment
mTabLayoutHelper.setAutoAdjustTabModeEnabled(true);This library is licensed under the Apache Software License, Version 2.0.
See LICENSE for full of the license text.
Copyright (C) 2015 Haruki Hasegawa
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.暂无开放 Issues,或尚未同步最近议题。