Change tabs text color in TabLayout to different colors programmatically

后端 未结 5 841
刺人心
刺人心 2021-01-18 14:02

I have 7 dates tabs in my screen, when tab selected, the text is black in color; while other select-able tabs are white in color. If the date falls on another month, I want

5条回答
  •  庸人自扰
    2021-01-18 14:28

    The solution based on my code above:

    ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
    //get view of the 6th tab - start with zero
    ViewGroup vgTabSixth = (ViewGroup) vg.getChildAt(5);
    //set the not-required tab color transparent ratio 20%
    vgTabSixth.setAlpha((float) 0.20);
    

提交回复
热议问题