找不到与给定名称匹配的资源:attr'android:tabLayout'

use*_*475 5 android tabwidget

我想通过用我自己的风格替换样式来自定义选项卡小部件.我要替换的项目如下:

 <item name="android:tabLayout">@android:layout/tab_indicator_holo</item>
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误:找不到与给定名称匹配的资源:attr'android:tabLayout'

我已经设置了这样的父样式:

<style name="customTabWidget" parent="@android:style/Widget.Holo.TabWidget">
Run Code Online (Sandbox Code Playgroud)

项目构建目标:Android 4.0

我也清理了项目,但错误仍然存​​在.如何修复错误?

提前致谢.

Der*_*rth 2

我遇到了类似的问题。解决方案的至少一部分是将 tabLayout 属性添加到 res/values/attrs.xml。以下是 TabWidget 样式的定义,从 android-16 平台复制而来(注意末尾的 tabLayout 属性):

<declare-styleable name="TabWidget">
    <!-- Drawable used to draw the divider between tabs. -->
    <attr name="divider" />
    <!-- Determines whether the strip under the tab indicators is drawn or not. -->
    <attr name="tabStripEnabled" format="boolean" />
    <!-- Drawable used to draw the left part of the strip underneath the tabs. -->
    <attr name="tabStripLeft" format="reference" />
    <!-- Drawable used to draw the right part of the strip underneath the tabs. -->
    <attr name="tabStripRight" format="reference" />
    <!-- Layout used to organize each tab's content. -->
    <attr name="tabLayout" format="reference" />
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)

由于您是重写的,因此您还需要更改:

 <item name="android:tabLayout">...
Run Code Online (Sandbox Code Playgroud)

到:

 <item name="tabLayout">...
Run Code Online (Sandbox Code Playgroud)