Android Xamarin使用

Android Xamarin使用,android,xamarin,xamarin.ios,xamarin.android,xamarin.forms,Android,Xamarin,Xamarin.ios,Xamarin.android,Xamarin.forms,我在应用程序的列表页面上使用FloatingActionButton,我还想添加一个搜索栏。但是我不能给他们看那一页。我的代码和截图都被删除了。如何显示搜索栏 晶圆厂 我的代码: <ContentPage.Content> <RelativeLayout> <SearchBar x:Name="searchBar" Placeholder="Ara" />

我在应用程序的列表页面上使用FloatingActionButton,我还想添加一个搜索栏。但是我不能给他们看那一页。我的代码和截图都被删除了。如何显示搜索栏

晶圆厂

我的代码:

<ContentPage.Content>
        <RelativeLayout>
      <SearchBar
             x:Name="searchBar"
             Placeholder="Ara"
             />
            <ContentView
                RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
                RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
                <ListView
                    x:Name="list"
                    BackgroundColor="White">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <TextCell
                                Text="{Binding .}" />
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </ContentView>
            <fab:FloatingActionButton
                x:Name="fabBtn"
                Source="plus.png"
                Size="Normal"
                Clicked="Handle_FabClicked"
                NormalColor="Green"
                RippleColor="Red"
                RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-75}"
                RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-75}" />
        </RelativeLayout>
    </ContentPage.Content>
</ContentPage>


@芝士巴龙是正确的。这个问题是因为这些视图相互重叠。相反,您需要向
ContentView
添加一个约束,使其
Y
位于
搜索栏的下方。考虑这样的事情:

<ContentView
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, Property=Height, ElementName=searchBar}" />


请注意,添加的
RelativeLayout.YConstraint
基于
搜索栏的
高度

iOS上的浮动操作按钮?你确定这个设计很适合iOS吗?是的,它工作得很好。不管怎样,看看你的代码,ContentView与你的搜索栏重叠,这就是为什么你看不到它。当我更改ContentView和搜索栏位置时,我看不到列表。请写正确的代码?