gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:06:54 25 4
gpt4 key购买 nike

我想通过将样式替换为我自己的样式来自定义选项卡小部件。我要更换的元素如下:

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

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

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

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

项目构建目标:Android 4.0

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

提前致谢。

最佳答案

我遇到了类似的问题。至少部分解决方案是将 tabLayout 属性添加到 res/values/attrs.xml。这是从 android-16 平台复制的 TabWidget 样式的定义(注意末尾的 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>

由于您正在覆盖,因此您还需要更改:

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

到:

 <item name="tabLayout">...

关于android - 找不到与给定名称 : attr 'android:tabLayout' 匹配的资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11816779/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com