zoukankan      html  css  js  c++  java
  • XF相对控件布局

    using System;
    using Xamarin.Forms;
    using Xamarin.Forms.Xaml;

    [assembly: XamlCompilation (XamlCompilationOptions.Compile)]
    namespace App6
    {
        public partial class App : Application
        {
            public App ()
            {
                InitializeComponent();
                BoxView bv = new BoxView { Color = Color.Red, WidthRequest = 150, HeightRequest = 150 };
                Label lbl = new Label { Text = "这是一个红色的方块", TextColor = Color.Red };
                RelativeLayout rl = new RelativeLayout();
                rl.Children.Add(bv,Constraint.RelativeToParent((parent)=>parent.Width/2),Constraint.RelativeToParent((parent)=>parent.Height/2));
                rl.Children.Add(lbl, Constraint.RelativeToView(bv, (parent, sibling) => sibling.X+bv.Width), Constraint.RelativeToView(bv, (parent, sibling) => sibling.Y));
                

                MainPage = new ContentPage { Content=rl};
            }

            protected override void OnStart ()
            {
                // Handle when your app starts
            }

            protected override void OnSleep ()
            {
                // Handle when your app sleeps
            }

            protected override void OnResume ()
            {
                // Handle when your app resumes
            }
        }
    }
     

  • 相关阅读:
    函数基础
    全局变量与类似配置文件的模块文件
    global语句(python学习手册422页)
    作用域实例
    变量名解析:LEGB原则
    作用域
    第三方库安装方法
    s[-1]和s[len(s)-1]
    查找特定后缀的文件
    logging日志管理-将日志写入文件
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434591.html
Copyright © 2011-2022 走看看