[英]Removing Tab Indicator from ViewPager
I have a ViewPager
that contains multiple tabs.我有一个包含多个选项卡的
ViewPager
。 There is a tab indicator at the top of the screen (the black strip in the following picture).屏幕顶部有一个选项卡指示符(下图中的黑色条)。 How do I disable the tab indicator?
如何禁用选项卡指示器?
Here's the code if needed:如果需要,这里是代码:
// ViewPager
ViewPager pager;
TeamTabAdapter tabAdapter;
REvent event;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Backup);
setContentView(R.layout.activity_team_viewer);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(getApplicationContext(), R.color.actionbar)));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
event = (REvent) getIntent().getSerializableExtra("event");
RTeam team = (RTeam) getIntent().getSerializableExtra("team");
RForm form = new Loader(getApplicationContext()).loadForm(event.getID());
tabAdapter = new TeamTabAdapter(getSupportFragmentManager(), event, team, form);
pager = (ViewPager) findViewById(R.id.pager);
pager.addOnPageChangeListener(this);
pager.setAdapter(tabAdapter);
pager.setCurrentItem(1);
}
I am not quite sure . 我不太确定。 But try adding transparent color like below in your TabLayout tag in xml
但是尝试在XML的TabLayout标记中添加如下所示的透明颜色
app:tabIndicatorColor="@android:color/transparent"
Removing Tab Indicator from ViewPager
从ViewPager移除标签指示符
Remove the PagerTabStrip
from the layout. 从布局中删除
PagerTabStrip
。 It will be a child of the ViewPager
. 这将是
ViewPager
的子ViewPager
。
How do I disable the tab indicator?
如何禁用选项卡指示器?
You can try calling setEnabled(false)
on the PagerTabStrip
, though I do not know if this works. 您可以尝试在
PagerTabStrip
上调用setEnabled(false)
,尽管我不知道这是否PagerTabStrip
。
This line app:tabIndicatorHeight="0dp"
solve the problem for me in xml.这行
app:tabIndicatorHeight="0dp"
为我解决了 xml 中的问题。
<android.support.design.widget.TabLayout
android:id="@+id/view_bottom_tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorHeight="0dp" //this line
app:tabGravity="fill"
app:tabMode="fixed" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.