2016-05-21 61 views
0

我正在使用Visual Studio。Xamarin中的Android自定義主題未找到

在我的MainActivity.cs文件中,我試圖設置一個自定義主題。活動屬性看起來像這樣:[Activity(Label = "MyTest", Icon = "@drawable/icon", Theme = "@android:style/Theme.Idkred", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

當我嘗試建立我得到:error APT0000: No resource found that matches the given name (at 'theme' with value '@android:style/Theme.Idkred').

我有一個價值觀文件夾中的我的Android資源文件夾中。有一個styles.xml文件。 styles.xml文件的構建操作是AndroidResource。

看起來它正在處理中,因爲在構建輸出中我看到了Processing: obj\Debug\res\values\styles.xml

我styles.xml文件中有這樣的:

<?xml version="1.0" encoding="utf-8"?> 

<resources> 

    <style name="Theme.Idkred" parent="@android:style/Theme.Holo.Light"> 
     <item name="android:actionBarItemBackground">@drawable/selectable_background_idkred</item> 
     <item name="android:popupMenuStyle">@style/PopupMenu.Idkred</item> 
     <item name="android:dropDownListViewStyle">@style/DropDownListView.Idkred</item> 
     <item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Idkred</item> 
     <item name="android:actionDropDownStyle">@style/DropDownNav.Idkred</item> 
     <item name="android:actionBarStyle">@style/ActionBar.Solid.Idkred</item> 
     <item name="android:actionModeBackground">@drawable/cab_background_top_idkred</item> 
     <item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_idkred</item> 
     <item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Idkred</item> 
    </style> 

... (more styles) 
</resources> 

回答

2

您必須刪除android:命名空間。

[Activity(Label = "MyTest", Icon = "@drawable/icon", Theme = "@style/Theme.Idkred", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] 

此命名空間僅適用於來自Android自身的資源。

+0

謝謝!那樣做了。 – bodangly