gpt4 book ai didi

c# - Xamarin - 动画 StackLayout

转载 作者:行者123 更新时间:2023-11-30 18:47:24 26 4
gpt4 key购买 nike

早上好,我正在尝试实现单击 StackPanel 上的 UserName 时的功能,以便键盘不会隐藏信息。但这不是最好的选择,我在 iOS 和 Android 上工作。你能帮帮我吗。

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BackGround.BackGroundImageDemo" BackgroundImage="Avion.jpg">
<ContentPage.Content >
<StackLayout VerticalOptions="Center" Padding="5, 50, 120, 0" BackgroundColor="White" HorizontalOptions="Center">
<Entry Placeholder="UserName" PlaceholderColor="Gray" TextColor="Navy" />
<Entry Placeholder="Password" IsPassword="true" PlaceholderColor="Gray" TextColor="Navy"/>
</StackLayout>

</ContentPage.Content>
</ContentPage>

Chase 应用程序有类似的东西。

Chase UserName normal - Chase in mode up stacklayout

最佳答案

这可以使用 ScrollView 来实现。这是一个简单的代码片段。

<ContentPage.Content>
<ScrollView x:Name="scr">

Your Stack Layout having entry and click button
Add TapGestureRecognizer to entry control in this case it is username or password whichever you want.
How to add TapGestureRecognizer. You can look at here.

</ScrollView>
</ContentPage.Content>

然后在你后面的代码上

field.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(async () =>
{
await ScollTest();
}),
NumberOfTapsRequired = 1,
});

private async void ScollTest()
{
// Then adjust your scroll this way.
await scr.ScrollToAsync(100, 1000, true);
}

关于c# - Xamarin - 动画 StackLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36016331/

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