android.support.design.widget.NavigationView.setItemIconTintList()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(239)

本文整理了Java中android.support.design.widget.NavigationView.setItemIconTintList()方法的一些代码示例,展示了NavigationView.setItemIconTintList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NavigationView.setItemIconTintList()方法的具体详情如下:
包路径:android.support.design.widget.NavigationView
类名称:NavigationView
方法名:setItemIconTintList

暂无

代码示例

代码示例来源:origin: xinghongfei/LookLook

Color.GRAY, Color.BLACK};
navView.setItemTextColor(new ColorStateList(state, color));
navView.setItemIconTintList(new ColorStateList(state, iconcolor));

代码示例来源:origin: oubowu/OuNews

@Override
  public void apply(View view, String resName) {
    ColorStateList colorList = getResourceManager().getColorStateList(resName);
    if (colorList == null) {
      L.e("找不到么");
      return;
    }
    if (view instanceof NavigationView) {
      L.e("view instanceof NavigationView");
      ((NavigationView) view).setItemTextColor(colorList);
      ((NavigationView) view).setItemIconTintList(colorList);
    } else {
      ((TextView) view).setTextColor(colorList);
    }
  }
},

代码示例来源:origin: LRH1993/LiveCircle

/**
 * 设置导航页信息
 */
private void setNavigationView() {
  //NavigationView初始化
  mAmNv.setItemIconTintList(null);
  View headerView = mAmNv.getHeaderView(0);
  mIv_photo = (ImageView) headerView.findViewById(R.id.iv_user_photo);
}

代码示例来源:origin: skylineTan/MaterialContacts

@Override protected void initViewsAndEvents() {
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer,
      toolbar, R.string.navigation_drawer_open,
      R.string.navigation_drawer_close);
  drawer.setDrawerListener(toggle);
  toggle.syncState();
  NavigationView navigationView = (NavigationView) findViewById(
      R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);
  navigationView.setItemIconTintList(null);
  mMainFragment = new MainFragment();
  getSupportFragmentManager().beginTransaction().add(R.id.main_container,
      mMainFragment).commit();
}

代码示例来源:origin: byhieg/easyweather

@Override
public void initView() {
  toolbar.setTitle("成都");
  setSupportActionBar(toolbar);
  if (getSupportActionBar() != null) {
    getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  }
  mNavigationView.setItemIconTintList(null);
  mNavigationView.setItemTextColor(null);
  ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
      toolbar, 0, 0);
  mDrawerToggle.syncState();
  drawerLayout.addDrawerListener(mDrawerToggle);
}

代码示例来源:origin: LiuGuiLinAndroid/LoveWallpaper

@SuppressLint("NewApi")
private void initView() {
  dialogShare = new CustomDialog(this, 0, 0, R.layout.dialog_share_item, R.style.Theme_dialog, Gravity.BOTTOM, R.style.pop_anim_style);
  ll_share_qq = (LinearLayout) dialogShare.findViewById(R.id.ll_share_qq);
  ll_share_qq.setOnClickListener(this);
  ll_share_sina = (LinearLayout) dialogShare.findViewById(R.id.ll_share_sina);
  ll_share_sina.setOnClickListener(this);
  ll_share_wechat = (LinearLayout) dialogShare.findViewById(R.id.ll_share_wechat);
  ll_share_wechat.setOnClickListener(this);
  ll_share_more = (LinearLayout) dialogShare.findViewById(R.id.ll_share_more);
  ll_share_more.setOnClickListener(this);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  drawer.setDrawerListener(toggle);
  toggle.syncState();
  NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);
  //显示原本的色彩
  navigationView.setItemIconTintList(null);
  initHomePager();
}

代码示例来源:origin: student9128/BottomNavigationBarForAndroid

mNavigationView.setItemIconTintList(null);
mNavigationView.setNavigationItemSelectedListener(this);
mNavigationView.setItemTextColor(ContextCompat.getColorStateList(this, R.color.bg_drawer_navigation));
mNavigationView.setItemIconTintList(ContextCompat.getColorStateList(this, R.color.bg_drawer_navigation));

代码示例来源:origin: sakurajiang/RestAPP

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  ButterKnife.bind(this);
  showDefaultFragment();
  mNavigationView.setItemIconTintList(null);
  mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
    @Override
    public void onDrawerSlide(View drawerView, float slideOffset) {
    }
    @Override
    public void onDrawerOpened(View drawerView) {
      isOpen = true;
    }
    @Override
    public void onDrawerClosed(View drawerView) {
      isOpen = false;
    }
    @Override
    public void onDrawerStateChanged(int newState) {
    }
  });
  initNavigationViewItemSelected();
}
public void showDefaultFragment(){

代码示例来源:origin: pushpalroy/GooglePlayCloned

@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);
}

代码示例来源:origin: konradrenner/kolabnotes-android

@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);
}

代码示例来源:origin: 18Gray/ProCamera

actionBar.setDisplayShowTitleEnabled(false);
navigation.setItemIconTintList(null);
View headerView = navigation.getHeaderView(0);
headerView.findViewById(R.id.iv_navigation_header).setOnClickListener(new View.OnClickListener()

代码示例来源:origin: JinBoy23520/CoderToDeveloperByTCLer

tv_rank = (TextView) headerView.findViewById(R.id.tv_rank);
navigationView.setNavigationItemSelectedListener(this);
navigationView.setItemIconTintList(null);
top_image.setOnClickListener(new View.OnClickListener() {
  @Override

代码示例来源:origin: bigsinger/fakegps

protected void initNavigationView() {
  mDrawerLayout = (DrawerLayout) findViewById(R.id.id_drawer_layout);
  mNavigationView = (NavigationView) findViewById(R.id.id_navigator_menu);
  mToolbar = (Toolbar) findViewById(R.id.id_toolbar);
  mToolbar.setBackgroundColor(ThemeUtils.getToolBarColor());
  setSupportActionBar(mToolbar);
  mToolbar.setTitleTextColor(Color.WHITE); //设置标题颜色
  getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  //创建返回键,并实现打开关/闭监听
  ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close);
  mDrawerToggle.syncState();
  mDrawerLayout.setDrawerListener(mDrawerToggle);
  setupDrawerContent(mNavigationView);
  mNavigationView.setItemIconTintList(ThemeUtils.getNaviItemIconTinkList());
  View headerView = mNavigationView.getHeaderView(0);
  headerView.setBackgroundColor(ThemeUtils.getToolBarColor());
  ImageView sdvHeader = (ImageView) headerView.findViewById(R.id.sdv_avatar);
  sdvHeader.setImageResource(R.drawable.ic_avtar);
  TextView appnameTextView = (TextView) headerView.findViewById(R.id.appnameTextView);
  appnameTextView.setText(getString(R.string.header_name) + Utils.getVersionInfo(this));
  // 自己写的方法,设置NavigationView中menu的item被选中后要执行的操作
  onNavgationViewMenuItemSelected(mNavigationView);
}

代码示例来源:origin: TobiasBielefeld/Simple-Solitaire

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_game_selector);
  NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  navigationView.setItemIconTintList(null);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  drawer.setDrawerListener(toggle);
  toggle.syncState();
  navigationView = (NavigationView) findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);
  tableLayout = (TableLayout) findViewById(R.id.tableLayoutGameChooser);
  if (!prefs.getSavedStartWithMenu()) {
    int savedGame = prefs.getSavedCurrentGame();
    if (savedGame != DEFAULT_CURRENT_GAME) {
      Intent intent = new Intent(getApplicationContext(), GameManager.class);
      intent.putExtra(GAME, savedGame);
      startActivityForResult(intent, 0);
    }
  } else {
    prefs.saveCurrentGame(DEFAULT_CURRENT_GAME);
  }
}

代码示例来源:origin: xujianhui404/SKinAppDemo

@Override
public void changeTheme(View view) {
  if(view instanceof NavigationView){
    NavigationView nv = (NavigationView) view;
    int selectColor = SkinManager.getInstance().getColor(R.color.nav_menu_select_color);
    int unSelectColor = SkinManager.getInstance().getColor(R.color.nav_menu_un_select_color);
    nv.setItemTextColor(createSelector(selectColor, unSelectColor));
    nv.setItemIconTintList(createSelector(selectColor, unSelectColor));
  }
}

代码示例来源:origin: PuffOpenSource/Puff-Android

navigationView.setItemIconTintList(null);
headerImageView = (ImageView) navigationView.getHeaderView(0).findViewById(R.id.header_image_view);
headerTextView = (TextView) navigationView.getHeaderView(0).findViewById(R.id.header_category);

代码示例来源:origin: UdacityAndroidDevScholarship/quiz-app

mDrawerLayout = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setItemIconTintList(null);
navigationView.setNavigationItemSelectedListener(this);

代码示例来源:origin: garretyoder/app-theme-engine

});
view.setItemTextColor(textSl);
view.setItemIconTintList(iconSl);

代码示例来源:origin: filestack/filestack-android

item.setIcon(info.getIconId());
nav.setItemIconTintList(ColorStateList.valueOf(theme.getAccentColor()));

代码示例来源:origin: xuancao/DynamicSkin

});
view.setItemTextColor(textSl);
view.setItemIconTintList(iconSl);

相关文章