How to change selected Tab Text color using TabLayout from code in Android?

后端 未结 8 907
悲哀的现实
悲哀的现实 2020-12-13 01:58

\"enter

I\'m using android.support.widget.TabLayout

8条回答
  •  失恋的感觉
    2020-12-13 02:18

    If you are using the design support library add this code to your tab activity.

    tabLayout.setSelectedTabIndicatorColor(Color.parseColor("#FF0000"));
    tabLayout.setSelectedTabIndicatorHeight((int) (5 * getResources().getDisplayMetrics().density));
    tabLayout.setTabTextColors(Color.parseColor("#727272"), Color.parseColor("#ffffff"));
    

    This will set the tab text color as well as tab indicator color in your tab activity.

提交回复
热议问题