私はEntryとButtonで構成されるシンプルなレイアウトを持っています。目標は、残りのスペースの下部にButtonを配置し、残りのスペースの中央にEntryを配置することです。すべてが最初に機能します。ここにレイアウトとスクリーンショットがあります。ソフトキーボードの表示/非表示時にScrollViewのレイアウトが正しく更新されない
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
NavigationPage.HasNavigationBar="False"
x:Class="ParentAdda.Pages.Test">
<ScrollView x:Name="Qq" Orientation="Vertical" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<StackLayout x:Name="Ww" Orientation="Vertical" VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<BoxView VerticalOptions="FillAndExpand" HeightRequest="0" BackgroundColor="Aquamarine" />
<Entry
FontSize="Medium"
Placeholder="+111111111"
HorizontalOptions="FillAndExpand"
Keyboard="Telephone" />
<BoxView VerticalOptions="FillAndExpand" HeightRequest="0" BackgroundColor="Coral" />
<Button Text="Update" Clicked="Button_OnClicked"
HorizontalOptions="Fill"
BorderRadius="20"
BackgroundColor="Lime"
TextColor="White"
FontSize="Large"
FontAttributes="Bold" />
</StackLayout>
</ScrollView>
</ContentPage>
私もFormsAppCompatActivity
を使用した場合、マニフェストに設定すると、タグがパンにリセットされたときXamarin.Formsに考慮にバグを取って、コード内で(Androidのプロジェクトにサイズを変更するWindowSoftInputModeを設定しています)
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
//https://bugzilla.xamarin.com/show_bug.cgi?id=39765
App.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
//https://bugzilla.xamarin.com/show_bug.cgi?id=39765
//Remove the status bar underlay in API 21+
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
Window.DecorView.SystemUiVisibility = 0;
var statusBarHeightInfo = typeof(FormsAppCompatActivity).GetField("_statusBarHeight", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
statusBarHeightInfo?.SetValue(this, 0);
Window.SetStatusBarColor(Android.Graphics.Color.Black);
}
}
エントリがフォーカス場合、ソフトキーボードが表示されている場合、私は一番下にスクロールすることができても、ページが
)(リサイズされていませんソフトキーボードが非表示になると、コンテンツのサイズが正しく変更されず、画面の一部しか占めなくなります。
ソフトキーボードが表示/非表示になる前に、レイアウトプロセスが境界に基づいて実行されているように見えます。ただし、ScrollViewのContentSize
プロパティ(ページ、ScrollView、StackLayoutのすべてのプロパティ)とのプロパティはすべて正しい数値を持っています(ボタンクリックされたハンドラでトレースされています)。私はForceLayout()
に、同じボタンをクリックしたハンドラーで異なる要素に電話してみました。
誰でもこの問題を解決する方法は知っていますか?