private void setIndicatorColor(TabLayout tabLayout,int color){ try { Field field = TabLayout.class.getDeclaredField("mTabStrip"); field.setAccessible(true); Object ob = field.get(tabLayout); Class<?> c = Class.forName("android.support.design.widget.TabLayout$SlidingTabStrip"); Method method = c.getDeclaredMethod("setSelectedIndicatorColor", int.class); method.setAccessible(true); method.invoke(ob, color); }catch (Exception e){} }
Android进阶——通过反射修改TabLayout 的颜色
最新推荐文章于 2021-06-19 17:05:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)