Xamarin.forms 我的钮扣如何居中?取决于我的第一个按钮
我试着将我的两个按钮居中,例如,我希望我的第一个按钮在中间,我的第二个按钮在我的第一个按钮旁边Xamarin.forms 我的钮扣如何居中?取决于我的第一个按钮,xamarin.forms,Xamarin.forms,我试着将我的两个按钮居中,例如,我希望我的第一个按钮在中间,我的第二个按钮在我的第一个按钮旁边 ----------------------------- - - - - - - - - - ----------- - - - 1 - 2 -
-----------------------------
- -
- -
- -
- -
- ----------- -
- - 1 - 2 - -
按钮应位于下止点
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Button Text="Here" BackgroundColor="Aqua" WidthRequest="100" />
<Button Text="Max" WidthRequest="50"
BackgroundColor="Yellow"/>
</StackLayout>
对于您想要实现的目标,您的代码应该如下所示:-
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Button Text="Here" BackgroundColor="Aqua" WidthRequest="100" HorizontalOptions="CenterAndExpand"/>
<Button Text="Max" WidthRequest="50" HorizontalOptions="Center" BackgroundColor="Yellow"/>
</StackLayout>
让我知道进一步的查询。您只想将第一个按钮居中,然后将第二个按钮放在它旁边吗
如果是,可以考虑使用./P>
我尝试了你的答案,但没有效果,你能给我一个截图吗?你能帮我解决这个问题吗
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Button Text="Here" BackgroundColor="Aqua" WidthRequest="100" HorizontalOptions="CenterAndExpand"/>
<Button Text="Max" WidthRequest="50" HorizontalOptions="Center" BackgroundColor="Yellow"/>
</StackLayout>
<RelativeLayout HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" BackgroundColor="Red">
<Button Text="Here" BackgroundColor="Aqua" WidthRequest="100" RelativeLayout.XConstraint ="{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=.5,
Constant= -50}"/>
<Button Text="Max" WidthRequest="50" BackgroundColor="Yellow" RelativeLayout.XConstraint ="{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=.5,
Constant= 60}"/>
</RelativeLayout>