这里是代码:codeshare.io/VZW3z3
在开始之前,我想提一下,遗憾的是,我的英语不是最好的,所以如果您发现任何错误,我深表歉意。现在,进入主题:我是一名来自乌克兰的年轻学生,目前正在接受大学教育。今年,我们学校给我们布置了一个任务:创建一个团队项目。尽管我之前没有移动开发经验(但我们了解 C#),但我和几个人决定使用 Xamarin.Forms 开发一个简单的蓝牙聊天应用程序。
从一开始,一切看起来都很好,但随着时间的推移,我们在基本功能和主要特性方面遇到了一些严重的问题。
我们的“搜索技巧”可能不是最好的,但我们正在努力——有些东西有效,有些则无效。然而,我们目前陷入了一些困境,非常感谢您的帮助,无论是建议、相关主题的链接还是代码片段。
如果您需要更多信息,包括我的部分代码或屏幕截图,请随时提问或联系。
以下是当前的问题之一:
适应性:在我们的模拟设备上一切看起来都很好,但在真实设备上却不然。也许Xamarin.Forms有一些通用的方法来确保所有设备上的一致性。在我们的应用程序中,所有页面都是使用网格制作的,我们找不到适应在不同设备上工作的可行解决方案,让我们看一个示例页面,这是隐私政策页面,最简单的一个,这就是我们使用它的原因。我们将把照片钉在下面。实际上,我们几乎每个页面都存在某种视觉问题。
为了理解,我们还将固定 xaml 页面代码。
希望我们在这里得到一些帮助,祝大家都有美好的一天!
我们阅读文档,到处都使用带有 Auto 和 * 属性的 Grid + 我们还使用 Stack Layout...我们不明白为什么它在真实设备上看起来如此糟糕
代码:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:B_Hedge"
x:Class="B_Hedge.PrivacyPolicy">
<Grid x:Name="BackgroundField" Background="{StaticResource FromRightLightTheme}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ImageButton Grid.Row="0" Clicked="GoBack" Source="{local:ImageResource B_Hedge.AddedFiles.Media.GoBack.png}"
HeightRequest="48" WidthRequest="48" CornerRadius="360" BorderColor="Black" BorderWidth="2" BackgroundColor="White"
HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand" Padding="8" Margin="8, 8, 0, 0"/>
<Frame Grid.Row="0" Grid.RowSpan="3" BackgroundColor="#A9DCF5" CornerRadius="16" HasShadow="True"
HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Margin="8, 32, 8, 0">
<StackLayout>
<Label Text="Privacy Policy" TextColor="Black" FontFamily="ExtraBold" FontSize="32"
HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
<Label Text="{StaticResource PrivacyPolicyText}"
TextColor="Black" FontFamily="SemiBold" FontSize="16"
HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
</StackLayout>
</Frame>
<Label Grid.Row="2" Text="Last Update was added 20.10.2023 by The B-Hedge Team"
TextDecorations="Underline" TextColor="Black" FontFamily="ExtraBold" FontSize="12"
HorizontalTextAlignment="Center" VerticalTextAlignment="End" Margin="0, 0, 0, 8"/>
</Grid>
</ContentPage>
我根据你的代码重现了你的问题。对于真机,您可以尝试以下代码来修复适配问题:
<ScrollView>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<ImageButton Grid.Row="0" ..../>
<!-- remove Grid.RowSpan="3" -->
<Frame Grid.Row="1">
<StackLayout>
.....
</StackLayout>
</Frame>
<Label Grid.Row="2" .../>
</Grid>
</ScrollView>
希望能帮到你:)