问题描述
我想有viewpageindicator在我的项目,但我有麻烦导入它。我在我的XML得到了错误。
I wanted to have viewpageindicator in my project, but am having trouble importing it. I've got errors in my XML.
Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.
Failed to find style 'vpiCirclePageIndicatorStyle' in current theme
我的XML文件:
My XML file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:layout_width="248dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_below="@id/pager"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:padding="3dip" />
</RelativeLayout>
我的更新RES /价值/ styles.xml
My updated res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="hololightnoactionbar" parent="android:Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="dividerstyle" parent="@android:style/Widget.ListView">
<item name="android:cacheColorHint">@android:color/transparent</item>
<item name="android:divider">@drawable/list_divider</item>
<item name="android:dividerHeight">1px</item>
</style>
<style name="roundedwhitebox">
<item name="android:background">@drawable/roundedwhitebox</item>
</style>
<style name="roundedlightgraybox">
<item name="android:background">@drawable/roundedlightgraybox</item>
</style>
<style name="rotatingProgressCircle">
<item name="android:indeterminateDrawable">@drawable/circleindeterminate</item>
</style>
<style name="StyledIndicators" parent="@android:style/Theme.Light">
<item name="vpiCirclePageIndicatorStyle">@style/CustomCirclePageIndicator</item>
<item name="vpiLinePageIndicatorStyle">@style/CustomLinePageIndicator</item>
<item name="vpiTitlePageIndicatorStyle">@style/CustomTitlePageIndicator</item>
<item name="vpiTabPageIndicatorStyle">@style/CustomTabPageIndicator</item>
<item name="vpiUnderlinePageIndicatorStyle">@style/CustomUnderlinePageIndicator</item>
</style>
<style name="CustomTitlePageIndicator">
<item name="android:background">#18FF0000</item>
<item name="footerColor">#FFAA2222</item>
<item name="footerLineHeight">1dp</item>
<item name="footerIndicatorHeight">3dp</item>
<item name="footerIndicatorStyle">underline</item>
<item name="android:textColor">#AA000000</item>
<item name="selectedColor">#FF000000</item>
<item name="selectedBold">true</item>
</style>
<style name="CustomLinePageIndicator">
<item name="strokeWidth">4dp</item>
<item name="lineWidth">30dp</item>
<item name="unselectedColor">#FF888888</item>
<item name="selectedColor">#FF880000</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>
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:textAppearance">@style/CustomTabPageIndicator.Text</item>
<item name="android:textColor">#FF555555</item>
<item name="android:textSize">16sp</item>
<item name="android:divider">@drawable/custom_tab_indicator_divider</item>
<item name="android:dividerPadding">10dp</item>
<item name="android:showDividers">middle</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingRight">8dp</item>
<item name="android:fadingEdge">horizontal</item>
<item name="android:fadingEdgeLength">8dp</item>
</style>
<style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
<item name="android:typeface">monospace</item>
</style>
<style name="CustomUnderlinePageIndicator">
<item name="selectedColor">#FFCC0000</item>
<item name="android:background">#FFCCCCCC</item>
<item name="fadeLength">1000</item>
<item name="fadeDelay">1000</item>
</style>
</resources>
我的项目结构是在这里,在这里vpilibrary是进口viewpageindicator库
My project structure is here, where vpilibrary is the imported viewpageindicator library
有什么不好呢?并且让我知道如果你需要更多的文件进行调试。 THX
What's wrong with it? and let me know if you need more files for debugging. Thx
PS:我的minSdkVersion和targetsdkversion既是16
ps:My minsdkversion and targetsdkversion is both 16
推荐答案
使用ViewPagerIndicator需要在其主题适当的样式的活动。
The activity using ViewPagerIndicator needs to have the appropriate styles in its theme.
在此示例项目,我演示设置了必要的自定义主题 vpiTabPageIndicatorStyle
:
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>
相同的基本方法应该适用 vpiCirclePageIndicatorStyle
,我会想象样品code伴随ViewPagerIndicator有一个这样的例子。
The same basic approach should work for vpiCirclePageIndicatorStyle
, and I would imagine that the sample code that accompanies ViewPagerIndicator has an example of this.
这篇关于无法找到风格vpiCirclePageIndicatorStyle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!