xamarin.form absolutelayout和Device.StartTimer

Posted jiecaoge

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xamarin.form absolutelayout和Device.StartTimer相关的知识,希望对你有一定的参考价值。

<ContentPage.Content>
        <AbsoluteLayout>
            <BoxView BackgroundColor="Red" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">
            </BoxView>
            <BoxView BackgroundColor="White" AbsoluteLayout.LayoutBounds="0.5,0.5,100,100" AbsoluteLayout.LayoutFlags="PositionProportional"></BoxView>
            <BoxView BackgroundColor="Blue" AbsoluteLayout.LayoutBounds="0,1,1,100" AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional"></BoxView>
        </AbsoluteLayout>
    </ContentPage.Content>

 

            AbsoluteLayout abs = new AbsoluteLayout();
            {
                BoxView b = new BoxView() { BackgroundColor = Color.Red };
                AbsoluteLayout.SetLayoutBounds(b, new Rectangle(0, 0, 1, 1));
                AbsoluteLayout.SetLayoutFlags(b, AbsoluteLayoutFlags.All);
                abs.Children.Add(b);
            }
            {
                BoxView b = new BoxView() { BackgroundColor = Color.White };
                AbsoluteLayout.SetLayoutBounds(b, new Rectangle(0.5, 0.5, 100, 100));
                AbsoluteLayout.SetLayoutFlags(b, AbsoluteLayoutFlags.PositionProportional);
                abs.Children.Add(b);
            }
            {
                BoxView b = new BoxView() { BackgroundColor = Color.Blue };
                AbsoluteLayout.SetLayoutBounds(b, new Rectangle(0, 1, 1, 60));
                AbsoluteLayout.SetLayoutFlags(b, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);
                abs.Children.Add(b);
            }
            this.Content = abs;

   

AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All"
其中AbsoluteLayout.LayoutBounds="0,0,1,1"代表X,Y,宽度,高度AbsoluteLayout.LayoutFlags="All"代表狂傲和Xy是以百分比的形式还是以像素点的形式显示,ALL代表全部都是百分比的形式
ALL代表所有的XY宽高都是以百分比的形式
PositionProportional代表XY是以百分比的形式
WidthProportional 代表宽度是以百分比的形式
None 代表所有的都不是以百分比的形式
HeightProportional 代表高度是以百分比的形式
XProportional 代表X轴是以百分比的形式
YProportional 代表Y周是以百分比的形式
SizeProportional 代表大小是以百分比的形式

<ContentPage.Content>
        <AbsoluteLayout>
            <Image Source="http://i1.umei.cc/uploads/tu/201811/9999/b21a1c8366.jpg" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">                
            </Image>
            <BoxView BackgroundColor="Black" Opacity="0.5" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All"></BoxView>
            <ActivityIndicator IsRunning="True" Color="White" AbsoluteLayout.LayoutBounds="0.5,0.5,0.1,0.1" AbsoluteLayout.LayoutFlags="All"></ActivityIndicator>
        </AbsoluteLayout>
    </ContentPage.Content>

  

in      int sleepsecount = int.MaxValue;
        int waitsecount = 0;
        public MainPage()
        {
            InitializeComponent();
            Device.StartTimer(TimeSpan.FromSeconds(1), () =>
            {
                this.label1.Text = waitsecount.ToString();
                return waitsecount++ < sleepsecount;
            });
        }

  








以上是关于xamarin.form absolutelayout和Device.StartTimer的主要内容,如果未能解决你的问题,请参考以下文章

Xamarin.Form 蓝牙ble

Xamarin.Form 初学 之 服务引用-WCF服务引用

Xamarin.Form指纹认证

xamarin.form MasterDetailPage

xamarin.form RelativeLayout

xamarin.form scrollView