How to change selected Tab Text color using TabLayout from code in Android?
问题 I'm using android.support.widget.TabLayout to make a Tab view, and I want to change the selected tabs text color from code (not from xml or by styling). How can I do this ? 回答1: 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