《Microsoft_Press_eBook_Xamarin_Preview_2_PDF》中文摘要

内容来自谷歌翻译+个人理解,因联系不上原作者,完全翻译有可能涉及版权,所以摘录一些精要。

方便自己和他人交流参考学习,期待大家一块翻译剩下的(排版没来得及折腾,见谅)。

环境:破解版Xamarin for Visual Studio 3.9.547,点我查看下载地址

备注1: 只有windows版本,没有相应mac破解,不过对于学习来说足够了

备注2: 此刻2018.1.23, 因为涉足html/js开发, 不再探究xamarin, 不过以目前雅思5.5分水平的成绩, 已经

完全可以看懂, 技术原版文档, 而无压力.

第一章:xamarin.forms适合什么情况?
1.oc,java,c#都是起源于c,所以有共同的地方。

(These three languages are cousins because they are all object-oriented descendants of C, but they
have 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#只支持基础的数据类型,intdoublestring,但是拓展的.net框架支持很多,它们包括。
At the lowest
level, .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 writing
4.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) as
usual, but it then makes use of the Apple compiler on the Mac to generate native iPhone machine
code just like the Objective-C compiler. The calls from the app to the iPhone APIs are the same as
though 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 are
mapped to platform-specific objects, but Xamarin.Forms has tended to avoid implementing anything
that 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.Forms
features 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 Visual
Studio running on a PC connected to the Mac via a network. Another option is to run Visual Studio in a
virtual 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 property
initialization in their page constructors. Following the Label constructor, a pair of curly braces enclose
one 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.” For
most 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
 FillAndExpand
5.文字重于形式。注重排版。
6.label设置了verticaloptions后,YAlign将不起作用。能设置BackgroundColor = Color .Yellow,
TextColor = Color .Green。//不过效果不太好。
(the result with this single line of text is the same as setting HorizontalOptions and
VerticalOptions 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 use
other colors that relate to the color theme of the operating system but that are not exposed through
Xamarin.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, and
you’ll need to know each platform’s supported font family names. For this reason, a demonstration of
FontFamily 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 dddd
6.默认的字体大小不是像素而是单位。These are not pixel sizes! As with the height of the iOS status bar, it’s best to refer to these sizes only
vaguely as some kind of “units.”
chapter 3 细说文本

 

posted on 2015-06-26 11:09  鸣动我心  阅读(432)  评论(0编辑  收藏  举报