禁用动作条选项卡指示器编程 [英] Disable ActionBar tab indicator programmatically
本文介绍了禁用动作条选项卡指示器编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能使用编程/ Java的code禁用选项卡指示器?
这是我如何设置等选项卡属性:
Is it possible to disable the tab indicator using programmatically/ Java code ?
This is how I am setting other tab properties :
actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#FFFFFF")));
ActionBar.TabListener
方法:
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
try {
if (tab.getPosition() == 4) {
listFlyout = null;
pwindo = null;
items.clear();
addFlyout();
} else if (tab.getPosition() == 0) {
tab.getIcon().setColorFilter(Color.parseColor("#10A595"), PorterDuff.Mode.SRC_IN);
selectedTabIndex = tab.getPosition();
} else if (tab.getPosition() == 1) { tab.getIcon().setColorFilter(Color.parseColor("#F25252"), PorterDuff.Mode.SRC_IN);
selectedTabIndex = tab.getPosition();
} else if (tab.getPosition() == 2) {
tab.getIcon().setColorFilter(Color.DKGRAY, PorterDuff.Mode.SRC_IN);
selectedTabIndex = tab.getPosition();
} else if (tab.getPosition() == 3) {
tab.getIcon().setColorFilter(Color.DKGRAY, PorterDuff.Mode.SRC_IN);
selectedTabIndex = tab.getPosition();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
tab.getIcon().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN);
}
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
if (tab.getPosition() == 4) {
listFlyout = null;
pwindo = null;
items.clear();
addFlyout();
}
}
但我得到的绿色我不希望选项卡指示器。
But I am getting green tab indicator which I don't want.
推荐答案
应用样式作为回答<一href="http://stackoverflow.com/questions/29339797/actionbar-tabs-set-dynamic-width-according-to-screen-width">here禁用该指标也是如此。一种解决方案固定两个问题对我来说:)
Applying the style as answered here disabled the indicator as well. One solution fixed two issues for me :)
这篇关于禁用动作条选项卡指示器编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文