【问题标题】:Android TabPageIndicator remove small lineAndroid TabPageIndicator 去掉小线
【发布时间】:2016-11-10 16:08:41
【问题描述】:

我做了这样的TabPageIndicator,我怎样才能去掉小线。已使用viewpagerindicator

【问题讨论】:

  • 显示你的布局代码。

标签: android viewpagerindicator


【解决方案1】:

您应该为Tabs 使用android 支持库而不是第三方库。

activity_main.xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"  />
</android.support.design.widget.CoordinatorLayout>

在代码中,您可以在一行代码中设置标签

        viewPager = (ViewPager) findViewById(R.id.viewpager);
        setupViewPager(viewPager);

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

然后将标签指示器的高度设置为 0 并将颜色设置为 tablayoutcolor 以使其消失

 TabLayout.setSelectedTabIndicatorHeight(int height)

对于颜色:

TabLayout.setSelectedTabIndicatorColor(int color)

你可以找到完整的例子here和与标签颜色相关的线程here

【讨论】:

    猜你喜欢
    • 2020-06-13
    • 1970-01-01
    • 1970-01-01
    • 2021-09-06
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 1970-01-01
    • 2021-12-18
    相关资源
    最近更新 更多