Java Code Examples for com.google.android.material.navigation.NavigationView#setItemIconTintList()

The following examples show how to use com.google.android.material.navigation.NavigationView#setItemIconTintList() . 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: NavigationViewActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Sets item icon tint list on the content of the navigation view. */
public static ViewAction setItemIconTintList(final @Nullable ColorStateList tint) {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isDisplayed();
    }

    @Override
    public String getDescription() {
      return "Set item icon tint list";
    }

    @Override
    public void perform(UiController uiController, View view) {
      uiController.loopMainThreadUntilIdle();

      NavigationView navigationView = (NavigationView) view;
      navigationView.setItemIconTintList(tint);

      uiController.loopMainThreadUntilIdle();
    }
  };
}
 
Example 2
Source File: ThemePrefs.java    From Easy_xkcd with Apache License 2.0 6 votes vote down vote up
public void setupNavdrawerColor(NavigationView navigationView) {
    int[][] state = new int[][]{
            new int[]{-android.R.attr.state_checked},
            new int[]{}
    };
    int[] color = new int[]{
            getNavDrawerTextColor(),
            getNavDrawerHightlightColor()
    };
    int[] colorIcon = new int[]{
            getColor(android.R.color.tertiary_text_light),
            getNavDrawerHightlightColor()
    };
    navigationView.setItemTextColor(new ColorStateList(state, color));
    navigationView.setItemIconTintList(new ColorStateList(state, colorIcon));
}
 
Example 3
Source File: NavigationViewUtil.java    From a with GNU General Public License v3.0 5 votes vote down vote up
public static void setItemIconColors(@NonNull NavigationView navigationView, @ColorInt int normalColor, @ColorInt int selectedColor) {
    final ColorStateList iconSl = new ColorStateList(
            new int[][]{
                    new int[]{-android.R.attr.state_checked},
                    new int[]{android.R.attr.state_checked}
            },
            new int[]{
                    normalColor,
                    selectedColor
            });
    navigationView.setItemIconTintList(iconSl);
}
 
Example 4
Source File: NavigationViewUtil.java    From MyBookshelf with GNU General Public License v3.0 5 votes vote down vote up
public static void setItemIconColors(@NonNull NavigationView navigationView, @ColorInt int normalColor, @ColorInt int selectedColor) {
    final ColorStateList iconSl = new ColorStateList(
            new int[][]{
                    new int[]{-android.R.attr.state_checked},
                    new int[]{android.R.attr.state_checked}
            },
            new int[]{
                    normalColor,
                    selectedColor
            });
    navigationView.setItemIconTintList(iconSl);
}
 
Example 5
Source File: MainActivity.java    From GooglePlayCloned with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    CustomViewPager viewPager = findViewById(R.id.mainViewPager);
    setupViewPager(viewPager);

    TabLayout tabLayout = findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);

    final FloatingSearchView mSearchView = findViewById(R.id.search_view);

    mSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() {
        @Override
        public void onSearchTextChanged(String oldQuery, final String newQuery) {

        }
    });

    final DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer,
            null,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setItemIconTintList(null);

    de.hdodenhof.circleimageview.CircleImageView profileImageView = navigationView.getHeaderView(0).findViewById(R.id.profile_image);
    Glide.with(this)
            .load(R.drawable.profile_image)
            .into(profileImageView);

    mSearchView.attachNavigationDrawerToMenuButton(drawer);
}
 
Example 6
Source File: MainActivity.java    From kolabnotes-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    initAccountSwitchedListeners();

    mAccountManager = AccountManager.get(this);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.activity_main);
    mNavigationView = (NavigationView) findViewById(R.id.navigation_view);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
            R.string.drawer_open, R.string.drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            overviewFragment.displayBlankFragment();
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.addDrawerListener(mDrawerToggle);

    mNavigationView.getHeaderView(0).findViewById(R.id.drawer_header).setOnClickListener(new OnHeaderClicked(mNavigationView));
    mNavigationView.setItemIconTintList(null);
}