Failed to find style vpiCirclePageIndicatorStyle

。_饼干妹妹 提交于 2019-12-04 00:03:11

Problem:

Solution:

  1. Add a custom style in res/layout/values/styles.xml

You can find some examples here.

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

<style name="CustomCirclePageIndicator">
    <item name="fillColor">#000000</item>
    <item name="strokeColor">#000000</item>
    <item name="strokeWidth">1dp</item>
    <item name="radius">6dp</item>
    <item name="centered">true</item>
</style>
  1. Add new style as a theme in your activity, "StyledIndicators":

    <activity
        android:name=".YourActivity"
        android:theme="@style/StyledIndicators" >
    </activity>
    
  2. After that just need to change to theme to the one that comes with the project, choose Manifest Themes - StyledIndicators.

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Light.NoTitleBar">
    <item name="vpiCirclePageIndicatorStyle">@style/CustomCirclePageIndicator</item>
</style>
<style name="CustomCirclePageIndicator">
    <item name="fillColor">#FF888888</item>
    <item name="strokeColor">#FF000000</item>
    <item name="strokeWidth">2dp</item>
    <item name="radius">10dp</item>
    <item name="centered">true</item>
</style>
</resources>

Now in your Manifest File. Add theme attribute under

<application
    android:icon="@drawable/icon"
    android:label="ViewPagerIndicator Sample"
    android:theme="@style/AppTheme" >

Dont forget to add

  android:theme="@style/AppTheme"

The activity using ViewPagerIndicator needs to have the appropriate styles in its theme.

In this sample project, I demonstrate setting up a custom theme with the requisite vpiTabPageIndicatorStyle:

<?xml version="1.0" encoding="utf-8"?>
<resources>

        <style name="AppTheme" parent="@style/Theme.Sherlock.Light">
                <item name="vpiTabPageIndicatorStyle">@style/TabStyle</item>
        </style>

        <style name="TabStyle" parent="Widget.TabPageIndicator">
                <item name="android:textColor">#FF33AA33</item>
                <item name="android:textSize">14sp</item>
                <item name="android:textStyle">italic</item>
                <item name="android:paddingLeft">16dp</item>
                <item name="android:paddingRight">16dp</item>
                <item name="android:fadingEdge">horizontal</item>
                <item name="android:fadingEdgeLength">8dp</item>
        </style>

</resources>

The same basic approach should work for vpiCirclePageIndicatorStyle, and I would imagine that the sample code that accompanies ViewPagerIndicator has an example of this.

To apply the custom style to the circle page indicator add the style attribute directly in your xml layout.

 <com.viewpagerindicator.CirclePageIndicator
        android:id="@+id/indicator"
        style="@style/CustomCirclePageIndicator"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:layout_width="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="20dp"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!