实现自定义主题的 Android 问题

标签 android themes

我的安卓项目

AndoidManifest.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="17" />

    <application
        android:allowBackup="true"
        android:debuggable="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@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>
        <activity 
            android:name="com.example.myfirstapp.DisplayMessageActivity"
            android:label="@string/title_activity_display_message"
            android:parentActivityName="com.example.myfirstapp.MainActivity" >
         <meta-data 
             android:name="android.support.PARENT_ACTIVITY"
             android:value="com.example.myfirstapp.MainActivity" /> 
        </activity>
    </application>


</manifest>

当我尝试在 res\values\themes.xml 下实现自定义主题时

<?xml version="1.0" encoding="utf-8"?>
<resources>
      <!-- the theme applied to the application or activity -->
      <style name="CustomActionBarTheme"  
          parent="@style/Theme.Holo.Light.DarkActionBar">
       <item name="android:actionBarStyle">@style/MyActionBar</item> 
       </style>      <!-- ActionBar styles -->

       <style name="MyActionBar"            
           parent="@style/Widget.Holo.Light.ActionBar.Solid.Inverse">
       <item name="android:background">@drawable/actionbar_background</item>
       </style>  
</resources>

我在指定时遇到错误

检索项目的父项时出错:找不到与给定名称“@style/Theme.Holo.Light.DarkActionBar”匹配的资源。检索项目的父项时出错:找不到与给定名称“@style/”匹配的资源 Widget.Holo.Light.ActionBar.Solid.Inverse'。

最佳答案

style前必须写android:,即@android:style/Theme.Holo.Light.DarkActionBar

关于实现自定义主题的 Android 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18756539/

相关文章:

android - 在另一个应用程序 Android 中启动一个应用程序

android - taplytics、mixpanel、optimized 或 apptimize 是如何工作的?

javascript - 钛中的三 Angular 函数值未给出正确的值

api 10 的 android volley https 响应代码 400

reactjs - 如何在react js中检查 Material ui主题的类型? (浅色或深色)

themes - Plone 4.2 - 如何更改 Diazo 主题中的 Logo ?

android - 在 Kindle Fire 上,是否可以获取用户的电子邮件地址?

javascript - 尝试为 qx.ui.embed.Html 制作一个带有 Non-Native 、 qooxdoo-Themed 滚动条的小部件

php - 如何在嵌套在不同文件夹和名称中的 Wordpress 子主题中加载 CSS 文件?

image - 如何在 Wordpress 中更改默认图像缩略图大小