认识Label控件

English:
program 程序
defined 定义
constructor 构造函数
platform 平台
deprecated 弃用
Deeper 深入
into 到..里
formatting 格式化
property 属性
using 使用

Xamrin 插件:

Thickness类:
在代码中设置填充位置,请使用Thickness类,它一共有3个构造函数,分别对应昨天说的三种方式。

Read EBook Xamrin Chapter 3:
一 . Deeper into Text
这讲述了Lable标签使用的color、fonts and formatting
Lable标签除了可以设置HorizontalOptions和VerticalOptions之外。
还可以设置HorizontalTextAlignment和VerticalTextAlignment。

HorizontalTextAlignment:文本在水平方向的位置:Center、Start、End
VerticalTextAlignment:文本在垂直方向的位置:Center、Start、End

在C#代码中所对应的类是:TextAlignment 

二、LineBreakMode
NoWrap, //不换行,超出部分隐藏

WordWrap,//单词为单位换行

CharacterWrap,//字符换行,即会出现单词隔断现象

HeadTruncation,//头部截断,省略头部文本以...代替

TailTruncation,//尾部截断

MiddleTruncation//中间截断

三、BackgroundColors
值:支持RGB、HSL或者直接写颜色名称
BackgroundColor 背景颜色设置
TextColor 设置文本颜色

设置Android的主题颜色:
    https://developer.xamarin.com/guides/xamarin-forms/platform-features/android/appcompat/

四、设置字体
FontFamil属性:值是字符串。
Node:字体必须在本机上有,比如 微软雅黑,如果把程序放到其他电脑上,请注意该电脑是否装了同样的字体。

五、格式化字体
可以为Label设置多段不同的字体,格式化的意思并非删除,而是更改文本格式。
上代码:

<Label HorizontalOptions="Fill" 
           VerticalOptions="Fill"
           BackgroundColor="Gray"
           HorizontalTextAlignment="End"
           VerticalTextAlignment="Center"
           LineBreakMode="WordWrap"
           TextColor="Yellow"
           FontFamily="微软雅黑"
           Text="Hello Label">

        <Label.FormattedText>
            <FormattedString>
                <FormattedString.Spans>
                    <Span Text="Rad" ForegroundColor="Red" FontAttributes="Bold" >
                    </Span>
                    <Span Text="Default"></Span>
                    <Span Text="italic smail " FontAttributes="Italic" FontSize="Small"></Span>
                </FormattedString.Spans>

            </FormattedString>

        </Label.FormattedText>

    </Label>

六、网络异步请求
HttpWebRequest类:

一、创建HttpWebReuqest类:
  HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));

二、设置请求类型:
    request.ContentType= "application/json";

三、设置请求方法:
     request.Method = "POST";

四、发送请求,并返回响应数据:

        using (WebResponse response = await request.GetResponseAsync())
        {

            using (Stream stream = response.GetResponseStream())
            {

                JsonValue jsonDoc = await Task.Run(() => JsonObject.Load(stream));

                return jsonDoc;
            }
        }

小细节:
Xamrin :

Device类:
Device.RuntimePlatform 获取当前运行的平台(IOS、Android、WinPhone)等
详情:https://www.jianshu.com/p/7804e6cec595

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值