【android】TabLayout文字闪烁问题
2015-12-24 15:08
453 查看
安卓MD设计提供了一个非常酷炫的效果,TabLayout拿来做选项卡时非常合适的,但是在实际使用中发现22.2.1版本号的TabLayout在ViewPager滑动的时候会出现闪烁现象。
2:要么使用22.0里最后一个没有bug的版本(compile 'com.android.support:design:22.2.0')
以上只是针对tabLayout文字闪烁的情况,如果图片闪烁要么升级到23.x
要么请参考以下方式自行解决,来源http://stackoverflow.com/questions/31828610/why-do-the-tablayouts-tabs-icons-texts-blink-when-swiping-between-pages
use the old version (22.2.0) as I've mentioned above.
you need to avoid using selectors for the icons. Use the exact image resource ids instead:
update the icons based on the page selections, as such:
Also, remember to call about the same loop when initializing the TabLayout. Something like that:
I think that this should also fix the issue for texts and not just icons.
解决方法:在gradle文件里
1:要么升级到23.x(compile 'com.android.support:design:23.1.1')2:要么使用22.0里最后一个没有bug的版本(compile 'com.android.support:design:22.2.0')
以上只是针对tabLayout文字闪烁的情况,如果图片闪烁要么升级到23.x
要么请参考以下方式自行解决,来源http://stackoverflow.com/questions/31828610/why-do-the-tablayouts-tabs-icons-texts-blink-when-swiping-between-pages
use the old version (22.2.0) as I've mentioned above.
you need to avoid using selectors for the icons. Use the exact image resource ids instead:
private static final int[] TAB_ICONS_UNSELECTED = {... }; private static final int[] TAB_ICONS_SELECTED = {... };
update the icons based on the page selections, as such:
mViewPager.addOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(final int position) { for (int i = 0; i < tabLayout.getTabCount(); ++i) tabLayout.getTabAt(i).setIcon(i != position ? TAB_ICONS_UNSELECTED[i] : TAB_ICONS_SELECTED[i]); } });
Also, remember to call about the same loop when initializing the TabLayout. Something like that:
for (int i = 0; i < tabLayout.getTabCount(); ++i) tabLayout.getTabAt(i).setIcon(i != mViewPager.getCurrentItem() ? TAB_ICONS_UNSELECTED[i] : TAB_ICONS_SELECTED[i]);
I think that this should also fix the issue for texts and not just icons.
相关文章推荐
- 使用AndroidStudio分析和解决ImageLoader引起内存泄露问题
- Android蓝牙打印二维码打印外卖单打印
- 在Android平台下搭建PhoneGap开发环境--用HTML5开发游戏
- android 第三方模拟器 genymotion安装问题修复
- 转: Android Studio你不知道的调试技巧
- Android开发笔记(二十六)Java的容器类
- Android系统基本情况介绍
- 安卓官方ViewPager与android.support.design.widget.TabLayout双向交互联动切换 。
- Android Studio 获取证书指纹(SHA1)
- Android之菜单选项子菜单submenu(二)
- Android Studio导入github中的项目
- Android中在Activity中加入其它的XML布局文件
- android开源图表框架HelloChart的使用 (hellocharts-library-1.5.8.jar)
- Android如何监听蓝牙耳机和有线耳机的插拔
- ProgressBar简单使用(1)
- 安卓屏幕--Android屏幕适配经验谈
- error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
- Android Broadcast广播机制 《第一行代码》
- AndroidStudio配置SVN以及使用代码管理
- 记录下最近在研究的使用AndroidStudio 实现untiy3d调用安卓内置的API接口实现刷新相册的功能