Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Divider not working for TitlePageIndicator with viewpagerindicator & actionbarsherlock

I noticed with the latest version of ViewPagerIndicator, ICS style dividers are supported, I tried to follow the issue and solution, but no matter what I do I can't get the divider to show up on my options on the actionbar for the TitlePageIndicator. I added the IcsLayout as the container, put divider, showDividers, and other properties, but am still getting nothing. Here's my layout (oddly enough, if I switch the IcsLayout to the viewpager indicator one, the app crashes):

<com.actionbarsherlock.internal.widget.IcsLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.sosick.android.brink"
    android:layout_width="match_parent"
    android:divider="#ffffff"
    android:showDividers="middle"
    android:dividerPadding="8dp"
    android:dividerHeight="10dp"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.viewpagerindicator.TitlePageIndicator
        android:id="@+id/tpi_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        textColor="@color/text_light"
        android:background="@drawable/ab_stacked_solid_brink"
        app:topPadding="10dp"
        app:footerPadding="15dp"
        app:footerColor="#a4ded7"
        app:footerIndicatorHeight="2dp"
        app:footerIndicatorStyle="underline"
        app:footerLineHeight="2dp"
        app:selectedBold="false" />

    <android.support.v4.view.ViewPager
        android:id="@+id/vp_pages"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

</com.actionbarsherlock.internal.widget.IcsLinearLayout>
like image 303
dariusriggins Avatar asked Feb 19 '13 18:02

dariusriggins


1 Answers

You need to declare divider params in styles, rather than in layout xml.

../res/values/styles.xml:

<style name="StyledIndicators" parent="@android:style/Theme.Light">
    <item name="vpiIconPageIndicatorStyle">@style/CustomIconIndicator</item>
</style>

<style name="CustomIconIndicator" parent="Widget.TabPageIndicator">
    <item name="android:divider">@drawable/custom_tab_indicator_divider</item>
    <item name="android:showDividers">middle</item>
    <item name="android:dividerPadding">10dp</item>
</style>

In manifest for your activity:

<activity
        android:name=".SampleIconsDefault"
        android:label="Icons/Default"
        android:theme="@style/StyledIndicators"> 
</activity>
like image 128
Pavel M. Avatar answered Nov 06 '22 14:11

Pavel M.