標籤:
內容來自Google翻譯+個人理解,因聯絡不上原作者,完全翻譯有可能涉及著作權,所以摘錄一些精要。
方便自己和他人交流參考學習,期待大家一塊翻譯剩下的(排版沒來得及折騰,見諒)。
環境:破解版Xamarin for Visual Studio 3.9.547,點我查看
(備忘:只有windows版本,沒有相應mac破解,不過對於學習來說足夠了)
第一章:xamarin.forms適合什麼情況?1.oc,java,c#都是起源於c,所以有共同的地方。(These three languages are cousins because they are all object-oriented descendants of C, but theyhave become rather distant cousins.) 2.c#份額繼續增長著,前途一片光明,通用的東西,linq,lambda運算式,非同步都使得它成為一門經典語言。更令人激動的是,.net在2014.4.3build大會上,c#建立者AndersHjlsberg宣布.net以前項目roslyn開源。(But C# has continued to grow and get better over the years. The support of generics, lambda functions, LINQ, and asynchronous operations has successfully elevated C# to be classified as a multiparadigm programming language.)3.底層c#只支援基礎的資料類型,int,double,string,但是拓展的.net架構支援很多,它們包括。At the lowestlevel, .NET provides an infrastructure for the C# basic data types (int, double, string, and so forth).But the extensive .NET Framework class library provides support for many common chores encountered in many different types of programming. These include:? Math? Debugging? Reflection? Collections? Globalization? File I/O? Networking? Security? Threading? Web services? Data handling? XML and JSON reading and writing4.share code,mvc->mvvm.view裡包含ui和對於ui的操作,vm只是管理資料。MVVM separates code into the Model (the underlying data), the View (the user interface, including visuals and input), and the ViewModel (which manages data passing between the Model and the View).5.c#->中繼語言IL->oc。When the iPhone app is built, the Xamarin C# compiler generates C# Intermediate Language (IL) asusual, but it then makes use of the Apple compiler on the Mac to generate native iPhone machinecode just like the Objective-C compiler. The calls from the app to the iPhone APIs are the same asthough the application were written in Objective-C.6. xamarin.forms從某種意義來說就是在各個平台建了個虛擬機器。In one sense, Xamarin.Forms is an API that virtualizes the user-interface paradigms on each platform.7.設定字型屬性,不能同時設定粗體和斜體,只能設定其中一個。FontAttributes = FontAttributes.Italic,8.局限性。xamarin.forms注重提取三個平台共有的原生組件,向量圖形或者複雜的觸控互動還是採用原生的好。(For the most part, Xamarin.Forms defines its abstractions with a focus on areas of the mobile user interface that are common to iOS, Android, and Windows Phone. These Xamarin.Forms visual objects aremapped to platform-specific objects, but Xamarin.Forms has tended to avoid implementing anythingthat is unique to a particular platform.)9.做產品原型很棒。Xamarin.Forms is great for prototyping or making a quick proof-of-concept application. And after you’ve done that, you might just find that you can continue using Xamarin.Formsfeatures to build the entire application. Xamarin.Forms is ideal for line-of-business applications.10. 開發環境,vs2013+mac或者,mac下裝vs的虛擬機器開發。This means that if you want to target all three platforms in a single IDE, you can do so with VisualStudio running on a PC connected to the Mac via a network. Another option is to run Visual Studio in avirtual machine on the Mac.11.如果想自己測試更多真實裝置,可以關注 Xamarin Test Cloud.
chapter 1 翻譯
第二章,剖析app。1.xamarin.forms已經有了三個類可供使用(目前破解版的3.9.525沒法使用?),The Xamarin.Forms application programming interface (API) defines classes named VisualElement, Page, Layout, and View.2.很多xamarin程式員更喜歡用c#3.0的規範寫代碼。(我們還有別的選擇嗎?似乎只有一個模板可以使用) Many Xamarin.Forms programmers prefer to use the C# 3.0 style of object creation and propertyinitialization in their page constructors. Following the Label constructor, a pair of curly braces encloseone or more property settings separated by commas.3.ios有個距離頂部20像素需要處理。 A little research in your favorite search engine will reveal that the iOS status bar has a height of 20.(Twenty what? you might ask. Twenty pixels? Actually, no. For now, just think of them as 20 “units.” Formost Xamarin.Forms programming you shouldn’t need to bother with numeric sizes, but Chapter 5,“Dealing with sizes,” will provide some guidance when you need to get down to the pixel level.)解決方案:①條件#if __IOS__Padding = new Thickness(0, 20, 0, 0);#endif②完美(device.onplatform(ios,android,winphone)): Padding = new Thickness( Device.OnPlatform( 200,50 , 5), 5, 5 , 5);4.水平垂直提供8種對齊。HorizontalOptions and VerticalOptions提供了8種狀態。如下? Start? Center? End? Fill? StartAndExpand? CenterAndExpand? EndAndExpand? FillAndExpand5.文字重於形式。注重排版。6.label設定了verticaloptions後,YAlign將不起作用。能設定BackgroundColor = Color .Yellow,TextColor = Color .Green。//不過效果不太好。(the result with this single line of text is the same as setting HorizontalOptions andVerticalOptions to Center, and you can also use various combinations of these properties to position the text in one of nine different locations around the page)
chapter 2 翻譯
1.水平和垂直對其預設屬性不是靠左對齊,而是預設填滿。The default value of HorizontalOptions and VerticalOptions is not LayoutOptions.Start,as the default appearance of the text might suggest. The default value is instead LayoutOptions.Fill.2.設定color.transparent意味著預設值,安卓下黑色,ios白色。但是設定其他顏色的時候要謹慎,因為有可能設定的顏色屬性,每個系統對於同樣顏色解析出來不同。But don’t try to just ignore all the platform defaults and explicitly set all the colors in your application to your own color scheme. This probably won’t work as well as you hope because many views useother colors that relate to the color theme of the operating system but that are not exposed throughXamarin.Forms properties.3.關於設定fontfamily,是個麻煩事,因為有些字型某些平台木有。The hardest of these to use is FontFamily. In theory you can set it to a font family name such as“Times Roman,” but it will work only if that particular font family is supported on the particular platform. For this reason, you’ll probably use FontFamily in connection with Device.OnPlatform, andyou’ll need to know each platform’s supported font family names. For this reason, a demonstration ofFontFamily must await a future chapter.4.formattedtext是格式化的text。可以自訂每一段字型的樣式,eg: var myFormattedString=new FormattedString(); var sp= new Span {Text = "aaa" , ForegroundColor = Color .Green}; var sp1 = new Span { Text = "bbb", ForegroundColor = Color.Red };new Label { FormattedText = myFormattedString,// Text = "Greetings, Xamarin.Forms!",XAlign = TextAlignment .Center,YAlign = TextAlignment .Center, }5.Text = "cc\u2019aaa\u2003ddddd"//cc‘aaa dddd6.預設的字型大小不是像素而是單位。These are not pixel sizes! As with the height of the iOS status bar, it’s best to refer to these sizes onlyvaguely as some kind of “units.”chapter 3 細說文本
《Microsoft_Press_eBook_Xamarin_Preview_2_PDF》中文摘要(持續更新中)