Xamarin.Android Visual Studio IntelliSense axml

在開發Xamarin.Android專案的Layout當中axml標記編輯時,也能IntelliSense的使用...

James Tsai 2016/04/29 20:51:42
899

主題

開發Xamarin.Android專案Layout當中axml標記編輯時,也能IntelliSense的使用

文章簡介

編輯Xamarin.Android專案的Layout當中axml標記編輯,常常會因為沒有IntelliSense可以用,造成編輯上的困擾,在本篇文章中將會介紹如何把IntelliSense找回來。

作者

James Tsai

版本/產出日期

V1.0/2016.4.29



1. 前言


近日在Visual Studio當中開發Xamarin.Android程式時,常常因為在Layout當中的axml標記編輯時,沒有辦法看到IntelliSense在開發上感到困擾。後來發現只要把相關的設定加好後,就可以在axml的標記編輯時有IntelliSense的協助囉!


2. 環境準備


Windows 8/8.1/10

Visual Studio 2015 / Xamarin Studio


3. 本文


Xamarin.Android編輯Layout中的axml標記編輯時沒有IntelliSense的問題


Xamarin.Android專案編輯Layout中的axml標記編輯時,可能會發生以下問題。也就是沒有出現IntelliSense來協助我們編輯相關的標記。



設定Layout當中axml標記編輯IntelliSense


Xamarin.Android在編輯axml的標記,其實跟Android編輯Xml的標記是一模一樣的,所以我們可以利用這樣的概念,來讓我們axml的標記編輯的時候能夠有IntelliSense可以使用。

首先找到在C:\Program Files (x86)\Xamarin Studio\AddIns\MonoDevelop.MonoDroid\schemas(若找不到此資料夾,請先安裝Xamarin Studio)底下的android-layout-xml.xsdschemas.android.com.apk.res.android.xsd這兩檔案,並且複製這兩檔案。



然後再到C:\Program Files (x86)\Microsoft Visual Studio 14.0\Xml\Schemas這個資料夾底下貼上,剛剛複製的android-layout-xml.xsdschemas.android.com.apk.res.android.xsd這兩檔案。



接著再回到Visual Studio當中,打開任何一個axml檔案的標記編輯,此時上方的選單就會多出一個XML的選項,在此XML的選單當中點選結構描述



XML結構描述對話窗當中點選加入



選到此C:\Program Files (x86)\Microsoft Visual Studio 14.0\Xml\Schemas這個資料夾底下的android-layout-xml.xsdschemas.android.com.apk.res.android.xsd這兩檔案。



XML結構描述對話窗當中確認加入無誤,點選確定



再次回到axml的標記編輯畫面,此時就會看到IntelliSense出現了。



4. 參考來源


How do I enable Intellisense in Android .axml files?

https://kb.xamarin.com/customer/portal/articles/1920119-how-do-i-enable-intellisense-in-android-axml-files-

James Tsai