Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Android ViewPager tabs divider?

How do I remove dividers from ViewPager?

Here is the code:

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bus.tralisto.MainActivity" 

/>

I cannot set android:Divider or anything I am used to. Does anyone have any idea how to remove them?

like image 958
Filip Luchianenco Avatar asked Nov 05 '14 08:11

Filip Luchianenco


2 Answers

I think we can "hack" this by making the divider transparent :

<style name="YourTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarTabBarStyle">@style/Divider</item>
</style>

<style name="Divider" parent="@android:style/Widget.Holo.ActionBar.TabBar">
    <item name="android:divider">@android:color/transparent</item> //or use your transparent drawable image
    <item name="android:showDividers">middle</item>
    <item name="android:dividerPadding">0dp</item>
</style>

Please told me whether it works or not. I never tested this code, but its working when i want to change my divider with my own image.

like image 132
Blaze Tama Avatar answered Oct 22 '22 20:10

Blaze Tama


The ViewPager is just the view that allows you to swipe horizontally between views (usually fragments), by default it hasn't tabs. You should look for some informations about ActionBar.Tab (see here. http://developer.android.com/training/implementing-navigation/lateral.html#tabs)

like image 41
rickyalbert Avatar answered Oct 22 '22 21:10

rickyalbert