您的位置:首页 > 移动开发 > Android开发

Missing styles. Is the correct theme chosen for this layout?

2016-12-14 10:43 441 查看
在我们使用第三方View框架时(如:TabPageIndicator),会定义theme属性,当启动项目时,会发现原有的ApplicationTheme样式没有生效(如:状态栏颜色),回到XML,Android Studio也会提示当前布局存在一些问题,部分提示信息如下:

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 'vpiTabPageIndicatorStyle' in current theme
java.lang.IllegalStateException: ViewPager has not been bound.


解决方案:

在Manifest内对应的使用单独theme的Activity,我们需要在这个Activity的theme里

android:theme="@style/StyledIndicatorsBGwhite"


点击进入style配置文件,application theme样式如下(个人示例):

<style name="AppTheme.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowBackground">@android:color/white</item>
<item name="android:screenOrientation">portrait</item>
</style>


而我们要修改的android:theme=”@style/StyledIndicatorsBGwhite”则在style文件内进入如下更改:

//在这个style name 后增加parent属性,值为application theme所对应的样式名,我的是AppTheme.NoActionBar

<style name="StyledIndicatorsBGwhite" parent="@style/AppTheme.NoActionBar">

//item的style为自己需要实现的style配置
<item name="vpiTabPageIndicatorStyle">@style/CustomTabPageIndicatorBGWhite</item>
</style>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android TabPageInd
相关文章推荐