react-native-navigation的迁移库

TopTabs.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.reactnativenavigation.views;
  2. import android.content.Context;
  3. import android.content.res.ColorStateList;
  4. import android.support.design.widget.TabLayout;
  5. import com.reactnativenavigation.params.StyleParams;
  6. public class TopTabs extends TabLayout {
  7. public TopTabs(Context context) {
  8. super(context);
  9. }
  10. void setSelectedTabIndicatorStyle(StyleParams style) {
  11. if (style.selectedTopTabIndicatorColor.hasColor()) {
  12. setSelectedTabIndicatorColor(style.selectedTopTabIndicatorColor.getColor());
  13. }
  14. if (style.selectedTopTabIndicatorHeight >= 0) {
  15. setSelectedTabIndicatorHeight(style.selectedTopTabIndicatorHeight);
  16. }
  17. }
  18. void setTopTabsTextColor(StyleParams style) {
  19. ColorStateList originalTabColors = getTabTextColors();
  20. int selectedTabColor = originalTabColors != null ? originalTabColors.getColorForState(TabLayout.SELECTED_STATE_SET, -1) : -1;
  21. int tabTextColor = originalTabColors != null ? originalTabColors.getColorForState(TabLayout.EMPTY_STATE_SET, -1) : -1;
  22. if (style.topTabTextColor.hasColor()) {
  23. tabTextColor = style.topTabTextColor.getColor();
  24. }
  25. if (style.selectedTopTabTextColor.hasColor()) {
  26. selectedTabColor = style.selectedTopTabTextColor.getColor();
  27. }
  28. setTabTextColors(tabTextColor, selectedTabColor);
  29. }
  30. }