Java Code Examples for android.support.design.widget.TabLayout#setBackgroundColor()

The following examples show how to use android.support.design.widget.TabLayout#setBackgroundColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorPrefUtil.java    From ColorPrefUtil with MIT License 5 votes vote down vote up
/**
 *  Change icon tint and text colors of NavigationView
 *
 *  @param backgroundColorId is the color TabLayout's background
 *  @param tabNormalTextColorId is the normal text color
 *  @param tabSelectedTextColorId is the selected tab text color
 */
public static void changeColorOfTabLayout(@NonNull Context context, @NonNull TabLayout tabLayout, @NonNull Integer backgroundColorId,
                                   @NonNull Integer tabNormalTextColorId,
                                   @NonNull Integer tabSelectedTextColorId,
                                   @NonNull Integer tabSelectedIndicatorColorId){
    tabLayout.setBackgroundColor(ContextCompat.getColor(context, backgroundColorId));
    tabLayout.setTabTextColors(ContextCompat.getColor(context, tabNormalTextColorId), ContextCompat.getColor(context, tabSelectedTextColorId));
    tabLayout.setSelectedTabIndicatorColor(ContextCompat.getColor(context, tabSelectedIndicatorColorId));
}
 
Example 2
Source File: ColorUtils.java    From android with Apache License 2.0 4 votes vote down vote up
public static void colorizeTabsAndHeader(Activity activity, Toolbar toolbar, TabLayout tabs,
    int primaryColor, int secondaryColor) {
  tabs.setBackgroundColor(primaryColor);
  tabs.setSelectedTabIndicatorColor(secondaryColor);
  colorizeHeader(activity, toolbar, primaryColor);
}