将搜索栏对准右中心

时间:2019-02-22 12:54:44

标签: c# forms xaml xamarin xamarin.forms

我正在尝试将搜索栏添加到“菜单栏”。它应该在条形图(y)的右侧(x)上,但它一直像这样:

enter image description here

这是我的代码的一部分:

            <RelativeLayout BackgroundColor="LightBlue" VerticalOptions="Start" HeightRequest="170" HorizontalOptions="FillAndExpand" >

                <RelativeLayout BackgroundColor="White" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
            Property=Height,Factor=.1,Constant=0}" HeightRequest="40" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}" >
                    <BoxView BackgroundColor="Black" HeightRequest="1" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
            Property=Height,Factor=0,Constant=0}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"/>
                    <Button Text ="H" WidthRequest="30" HeightRequest="30" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Y, Factor=0.5, Constant=0}" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=X, Factor=0, Constant=1}" />

                    <SearchBar x:Name="searchcustomer" Placeholder="Search" HeightRequest="30" WidthRequest="100" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Y, Factor=0.5, Constant=0}" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=X, Factor=1, Constant=0}"/>
                   
                    <BoxView BackgroundColor="Black" HeightRequest="1" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
            Property=Height,Factor=1,Constant=0}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"/>
                </RelativeLayout>


                <StackLayout
         RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
         RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}">
                    <StackLayout Orientation="Horizontal" VerticalOptions="EndAndExpand" HorizontalOptions="Center" Spacing="50">
                        <Label x:Name="NewsButton" Text="News" Font="Bold, 24" TextColor="white"/>
                        <Label x:Name="TaskButton" Text="Tasks" Font="Bold, 24" TextColor="white"/>
                    </StackLayout>
                </StackLayout>

            </RelativeLayout>

有人知道如何解决此问题吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

您可以使用#include <string> #include "test.h" . . . 代替<VictoryChart > <VictoryGroup colorScale={["tomato", "orange"]} > <VictoryLine size={7} data={ [ { x: '\'08-\'09', y: 13.2}, { x: '\'10-\'11', y: 9.3}, { x: '\'12-\'13', y: 7}, { x: '\'14-\'15', y: 8.5} ] } y0={0} x={axisData} interpolation="natural" /> <VictoryLine size={7} data={ [ { x: '\'08-\'09', y: 1.96 }, { x: '\'10-\'11', y: .95 }, { x: '\'12-\'13', y: .58 }, { x: '\'14-\'15', y: .9 } ] } x={axisData} interpolation="natural" /> </VictoryGroup> <VictoryAxis tickFormat={axisData} offsetY={30} tickLabelComponent={<VictoryLabel textAnchor="start" />} /> <VictoryAxis tickFormat={(t) => `${Math.round(t)}%`} dependentAxis offsetX={45} /> </VictoryChart> 。请参考以下代码。

Grid

它看起来像下面的屏幕截图。

enter image description here