繁体   English   中英

Android:自定义操作栏主题错误-(未找到匹配的资源。。。)

[英]Android: Custom Action Bar Theme Error - (No Resource Found that Matches . . .)

我正在Eclipse中使用Android。

因此,我尝试实现自定义主题,并且不断从清单文件中收到此错误:

 error: Error: No resource found that matches the given name (at 'theme' with value   
'@android:style/CustomActionBarTheme').

有想法吗? 谢谢!

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/CustomActionBarTheme" >
    <activity
        android:name="com.example.myfirstapp.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <!--  A child of the main activity -->
    <activity
        android:name="com.example.myfirstapp.DisplayMessageActivity"
        android:label="@string/title_activity_display_message"
        android:parentActivityName="com.example.myfirstapp.MainActivity" >
        <!-- Parent activity meta-data to support 4.0 and lower --> 
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.myfirstapp.MainActivity" />
    </activity>
</application>

</manifest>

Themes.xml(自定义主题)

<?xml version="1.0" encoding="utf-8"?>
<resources> 
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
       parent="@android:style/Theme.Holo">
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="android:actionMenuTextColor">@color/actionbar_text</item>
</style>

<!-- ActionBar Styles -->
<style name="MyActionBar"
       parent="android:style/Widget.Holo.ActionBar">
    <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>

<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
       parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/actionbar_text</item>
</style>

<!-- ActionBar tabs text styles -->
<style name="MyActionBarTabText"
       parent="@android:style/Widget.Holo.ActionBar.TabText">
       <item name="android:textColor">@color/actionbar_text</item>
</style>
</resources>

Styles.xml

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@android:Theme.Holo.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here.
 -->
</style>

</resources>

使用@android:...时,您正在引用系统资源。 而是使用@style/CustomActionBarTheme

您需要使用

android:theme="@style/CustomActionBarTheme

您是在themes.xml中引用样式。

没有名称为@android:style/CustomActionBarTheme

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM