当前位置:网站首页>Introduction to smarttablayout
Introduction to smarttablayout
2022-04-22 08:29:00 【GuoXuan_ CHN】
This is a reprinted article , The original address of the article is :https://www.jianshu.com/p/1fef849fd1eb
If there is any infringement , Inform that it is necessary to delete .
Project address :
https://github.com/ogaclejapan/SmartTabLayout
Introduce :
A custom ViewPager tab instructions , It can make users feel the of the whole process when sliding UI feedback .
Instructions :
build.gradle.
dependencies { compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar' //Optional: see how to use the utility. compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar' //Optional: see how to use the utility. compile 'com.ogaclejapan.smarttablayout:utils-v13:1.6.1@aar' } take SmartTabLayout Control into the layout , Generally speaking, it is placed in ViewPager On top of .
<com.ogaclejapan.smarttablayout.SmartTabLayout
android:id="@+id/viewpagertab"
android:layout_width="match_parent"
android:layout_height="48dp"
app:stl_indicatorAlwaysInCenter="false"
app:stl_indicatorInFront="false"
app:stl_indicatorInterpolation="smart"
app:stl_indicatorColor="#40C4FF"
app:stl_indicatorThickness="4dp"
app:stl_indicatorCornerRadius="2dp"
app:stl_underlineColor="#4D000000"
app:stl_underlineThickness="1dp"
app:stl_dividerColor="#4D000000"
app:stl_dividerThickness="1dp"
app:stl_defaultTabTextAllCaps="true"
app:stl_defaultTabTextColor="#FC000000"
app:stl_defaultTabTextSize="12sp"
app:stl_defaultTabTextHorizontalPadding="16dp"
app:stl_defaultTabTextMinWidth="0dp"
app:stl_distributeEvenly="false"
/>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/viewpagertab"
/>
stay onCreate perhaps onCreateView in , take ViewPager Bind to our controls ( If you use... In the tool catalog FragmentPagerItemAdapter, You can easily item To PagerAdapter in )
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter( getSupportFragmentManager(), FragmentPagerItems.with(this) .add(R.string.titleA, PageFragment.class) .add(R.string.titleB, PageFragment.class) .create()); ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setAdapter(adapter); SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab); viewPagerTab.setViewPager(viewPager);
( Optional ) If you use OnPageChangeListener, Please put OnPageChangeListener Set to viewPagerTab, Instead of calling directly ViewPager Of setOnPageChangeListener.
viewPagerTab.setOnPageChangeListener(mPageChangeListener);
( Optional ) Use FragmentPagerItemAdapter, It's easy to get Fragment Where position
int position = FragmentPagerItem.getPosition(getArguments());
How to use utils
Utility has two types available to suit the Android support library.
There are two utils
utils-v4 Contains suitable android.support.v4.app.Fragment Of PagerAdapter.
utils-v13 Contains suitable android.app.Fragment Of PagerAdapter.
These two tools just rely on different , The implementation function is the same .
be based on view Of PagerAdapter
ViewPagerItemAdapter adapter = new ViewPagerItemAdapter(ViewPagerItems.with(this) .add(R.string.title, R.layout.page) .add(ViewPagerItem.of("title", R.layout.page)) .create()); viewPager.setAdapter(adapter); //... public void onPageSelected(int position) { //.instantiateItem() from until .destoryItem() is called it will be able to get the View of page. View page = adapter.getPage(position); }
be based on Fragment Of PagerAdapter
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter( getSupportFragmentManager(), FragmentPagerItems.with(this) .add(R.string.title, PageFragment.class), .add(R.string.title, WithArgumentsPageFragment.class, new Bundler().putString("key", "value").get()), .add(FragmentPagerItem.of("title", PageFragment.class)) .create()); viewPager.setAdapter(adapter); //... public void onPageSelected(int position) { //.instantiateItem() from until .destoryItem() is called it will be able to get the Fragment of page. Fragment page = adapter.getPage(position); }
版权声明
本文为[GuoXuan_ CHN]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220735463770.html
边栏推荐
- PWM output of STM32 to steering gear sg90
- 每日一题冲刺大厂第十五天 终于结束的起点
- 华为机试题——HJ53 杨辉三角的变形
- eventBus
- 反转一个链表<难度系数>
- 重启redis
- Hanyuan hi tech PDH optical transceiver double optical port protection + 4-way E1 + 4-way Gigabit Network + 4-way 100m network optical transceiver
- Redis非关系型数据库—Redis高可用、持久化及性能管理
- The starting point of the final end of the 15th day of the sprint to the big factory
- Handler相关源码分析
猜你喜欢

Flutter 判断网络可用性

ViewPager 全面总结

Flutter ListView 加载更多

tensorflow使用笔记

The domestic cloud security market has exceeded 10 billion yuan. What is the future development trend?

Pycharm terminal PIP installation error: "PIP" item is recognized as the name of cmdlet, function, script file or runnable program

Cr doped strontium titanate Cr: SrTiO3 crystal substrate | NaCl < 111 > 10x10x2 0mm1sp crystal substrate | Al2O3 sapphire crystal substrate | Qiyue biology

Fresco简单的使用—SimpleDraweeView

使⽤airtestIDE⽣成脚本,使⽤脚本运⾏

Cloud computing learning 2 - keystone component operation and maintenance and testing
随机推荐
Fluorescent labeled polypeptide / amino acid (FITC modified / AMC modified) Qiyue organism
Redis数据服务器/数据库/缓存(2022)
SQL requirements processing - count the number of Mondays to Sundays in a given year
进程和线程
Layer1 capacity expansion: fragmentation and composability
微服务(分布式架构)
【大话云原生】微服务篇-五星级酒店的服务方式
shell脚本中ps -ef查询进程PID一直返回异常
Experiment 2: mathematical basis in Data Science
Informatics Aosai yibentong 1317: [example 5.2] combined output
CPU的基本工作流程
Flutter Modul类与Json相互转换
Network principle II (Part I)
Golang learning, pointer, loop control, correlation
wepy学习记录
3-1 compare size
shell脚本学习——实战案例
spark sql 获取数组某index处元素
Asnotracking for efcore optimization
Airtest installation and introduction