No resource found that matches the given name: attr 'android:tabLayout'

杀马特。学长 韩版系。学妹 提交于 2019-12-06 03:29:31

问题


I would like to customize tab widget by replacing the style with my own style. The item I am going to replace is as follow :

 <item name="android:tabLayout">@android:layout/tab_indicator_holo</item>

But I got this error : No resource found that matches the given name: attr 'android:tabLayout'

I have set the parent style like this :

<style name="customTabWidget" parent="@android:style/Widget.Holo.TabWidget">

The Project build target : Android 4.0

I also have cleaned the project but the error still exits. How to fix the error?

Thanks in advance.


回答1:


I encountered a similar problem. At least part of the solution is to add the tabLayout attribute to res/values/attrs.xml. Here is the definition of the TabWidget styles, copied from the android-16 platform (notice the tabLayout attribute at the end):

<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>

Since you are overriding, you will also want to change:

 <item name="android:tabLayout">...

to:

 <item name="tabLayout">...


来源:https://stackoverflow.com/questions/11816779/no-resource-found-that-matches-the-given-name-attr-androidtablayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!