2015-12-28 50 views
1

这里是我当前选项卡的布局:如何在android中自定义TabLayout?

<android.support.design.widget.TabLayout 
    android:id="@+id/tab_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/pager" 
    android:background="?attr/colorPrimary" 
    android:elevation="6dp" 
    android:minHeight="?attr/actionBarSize" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    /> 

这使得屏幕看起来是这样的:

enter image description here

我想圆导航(我不知道的是,确切的术语)所以,我附上一张照片:

enter image description here

正如你可以看到,当我浏览屏幕上的可滑动选项卡,我应该关注与当前页面对应的圆圈编号(在我的情况下,它应该是深灰色的,而其他的则是浅灰色的)。 您可以在页面底部看到圆圈。

我知道我可以让这些圆圈成为片段的一部分,然后让各自的圆圈成为焦点,但随后,每次滑动,圆圈组也会被刷掉 - 这是我不想要的。

有没有办法做到这一点?

+0

检查该链接tablayout http://stackoverflow.com/a/17898875/2826147 –

+0

那insted的只是使用HTTPS: //github.com/PaoloRotolo/AppIntro –

+0

你见过http://stackoverflow.com/questions/30892545/tablayout-with-icons? – PPartisan

回答

-2

您可以通过使用viewpager来实现此目的。最常见的viewpager指标是杰克华顿的http://viewpagerindicator.com/。它的使用与工作室

后,你宣布你的插件添加到您的源库与ViewPager从Android支持库

也兼容:

repositories { 
    maven { url "http://dl.bintray.com/populov/maven" } 
    mavenCentral() 
} 

而在模块的build.gradle文件中添加依赖

dependencies { 
    // ... 
    compile 'com.viewpagerindicator:library:2.4.1' 
    // ... 
} 
+0

此库已弃用 – galex

相关问题