gpt4 book ai didi

android - Xamarin 形成 RelativeLayout 使用

转载 作者:行者123 更新时间:2023-11-30 00:48:02 26 4
gpt4 key购买 nike

我在应用程序的列表页面上使用了 FloatingActionButton,我还想添加一个 searchBar。但我无法向他们展示该页面。我的代码和屏幕截图已关闭。如何显示搜索栏?

FAB Github

我的代码:

<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>

enter image description here

最佳答案

@Cheesebaron 是正确的。问题是因为 View 彼此重叠。相反,您需要向 ContentView 添加约束,使其 Y 位于 searchBar 下方。考虑这样的事情:

<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 将基于 searchBarHeight

关于android - Xamarin 形成 RelativeLayout 使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41505487/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com