简体   繁体   English

从 ViewPager 中删除选项卡指示器

[英]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.

相关问题 圆形ViewPager指示器,例如Galaxy Tab2 - Circular ViewPager Indicator like Galaxy Tab2 如何沿 Viewpager 显示圆形选项卡指示器? - How to show a circle tab indicator along Viewpager? 如何更改Material ViewPager选项卡指示器文本的颜色? - How to change material viewpager tab indicator text color? Android选项卡页面指示器将viewpager的底部置于行lindicator的顶部 - Android tab page indicator place bottom of viewpager with line lindicator on top 从图库中选择图像的Viewpager指示器 - Viewpager indicator with images selected from gallery 如何使用ViewPager滑动标签页时更改标签页指示器颜色和文本颜色? - How to change tab indicator color and text color while swiping tab using ViewPager? FragmentStateAdapter 删除最后一个选项卡而不是当前的 ViewPager2 - FragmentStateAdapter removing last tab instead of current ViewPager2 从ActionBar主页指示器移除左边界 - Removing left margin from ActionBar home indicator 从Android中的RecycleView中删除焦点指示符 - Removing focus indicator from RecycleView in Android 如何从FragmentTabhost中删除选定的选项卡指示器? - How to remove the selected tab indicator from the FragmentTabhost?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM