标签:ESS 高度 ntp 设置 nta page 位置 etop htc
<ContentPage.Content> <RelativeLayout> <BoxView Color="Red" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.15,Constant=0}" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.15,Constant=0}" RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.7,Constant=0}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.7,Constant=0}" > </BoxView> </RelativeLayout> </ContentPage.Content>
可以设置4个属性YConstraint,XConstraint,HeightConstraint,WidthConstraint
其中Contant是按照像素点偏移的值,Type是针对哪个控件的偏移有RelativeToParent和RelativeToView,ElementName是针对哪个控件做偏移只有在ReleativeToView的时候用到,Property是针对控件的哪个属性做偏移,
ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.15,Constant=0的意思是针对上层元素的高度,用高度*0.15+0的实际位置
BoxView b = new BoxView() { BackgroundColor = Color.Red }; relative1.Children.Add(b , Constraint.RelativeToParent((parent) => { return parent.X * 0.5; }) , Constraint.RelativeToParent((parent) => { return parent.Y * 0.5; }) , Constraint.RelativeToParent((parent) => { return parent.X * 0.5; }) , Constraint.RelativeToParent((parent) => { return parent.X * 0.5; }) );
标签:ESS 高度 ntp 设置 nta page 位置 etop htc
原文地址:https://www.cnblogs.com/jiecaoge/p/10029965.html