私はXamarinフォームの最新バージョンを使用しています。私はコンテンツページを持つカルーセルページを持っています。コンテンツページには、スクロールビューがあり、いくつかのラベルと入力入力を含むスタックレイアウトがあります。入力をタッチしてテキストを入力すると、キーボードが入力ボックスを覆い、入力したものが表示されません。私のXamarinフォームPCLカルーセルページのキーボードは、自分の入力フィールドをカバーしています
私はベーシックアプリで、8個のラベルと8個のエントリを持つコンテンツページ(カルーセルなし)を使用し、キーボードが表示されているときにエントリボックスが上にスクロールして表示されることをテストしましたに。
しかし、上記のコンテンツページを子供として追加するカルーセルページを使用すると、キーボードは自分の入力フィールドをカバーします。
ので、下記の作品:
public App()
{
InitializeComponent();
MainPage = new MainPage1();
}
namespace App2
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage1 : ContentPage
{
public MainPage1()
{
InitializeComponent();
var vScrollView = new ScrollView
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.FillAndExpand,
Margin = new Thickness(0, 5, 15, 25),
};
var vStackLayout = new StackLayout
{
Orientation = StackOrientation.Vertical,
Spacing = 10,
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Start,
Margin = new Thickness(15, 0, 15, 25),
WidthRequest = 700
};
//Create the form label for the item
var lblItemLabel = new Label
{
Text = "Label 1",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Margin = new Thickness(10, 0, 0, 0),
};
vStackLayout.Children.Add(lblItemLabel);
var entry = new Entry
{
//HorizontalOptions = LayoutOptions.Fill,
MinimumWidthRequest = 300,
Margin = new Thickness(20, 0, 15, 15),
};
vStackLayout.Children.Add(entry);
var lblItemLabel2 = new Label
{
Text = "Label 2",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Margin = new Thickness(10, 0, 0, 0),
};
vStackLayout.Children.Add(lblItemLabel2);
var entry2 = new Entry
{
//HorizontalOptions = LayoutOptions.Fill,
MinimumWidthRequest = 300,
Margin = new Thickness(20, 0, 15, 15),
};
vStackLayout.Children.Add(entry2);
var lblItemLabel3 = new Label
{
Text = "Label 3",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Margin = new Thickness(10, 0, 0, 0),
};
vStackLayout.Children.Add(lblItemLabel3);
var entry3 = new Entry
{
//HorizontalOptions = LayoutOptions.Fill,
MinimumWidthRequest = 300,
Margin = new Thickness(20, 0, 15, 15),
};
vStackLayout.Children.Add(entry3);
var lblItemLabel4 = new Label
{
Text = "Label 4",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Margin = new Thickness(10, 0, 0, 0),
};
vStackLayout.Children.Add(lblItemLabel4);
var entry4 = new Entry
{
//HorizontalOptions = LayoutOptions.Fill,
MinimumWidthRequest = 300,
Margin = new Thickness(20, 0, 15, 15),
};
vStackLayout.Children.Add(entry4);
var lblItemLabel5 = new Label
{
Text = "Label 5",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Margin = new Thickness(10, 0, 0, 0),
};
vStackLayout.Children.Add(lblItemLabel5);
var entry5 = new Entry
{
//HorizontalOptions = LayoutOptions.Fill,
MinimumWidthRequest = 300,
Margin = new Thickness(20, 0, 15, 15),
};
vStackLayout.Children.Add(entry5);
var lblItemLabel6 = new Label
{
Text = "Label 6",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Margin = new Thickness(10, 0, 0, 0),
};
vStackLayout.Children.Add(lblItemLabel6);
var entry6 = new Entry
{
//HorizontalOptions = LayoutOptions.Fill,
MinimumWidthRequest = 300,
Margin = new Thickness(20, 0, 15, 15),
};
vStackLayout.Children.Add(entry6);
var lblItemLabel7 = new Label
{
Text = "Label 7",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Margin = new Thickness(10, 0, 0, 0),
};
vStackLayout.Children.Add(lblItemLabel7);
var entry7 = new Entry
{
//HorizontalOptions = LayoutOptions.Fill,
MinimumWidthRequest = 300,
Margin = new Thickness(20, 0, 15, 15),
};
vStackLayout.Children.Add(entry7);
var lblItemLabel8 = new Label
{
Text = "Label 8",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Margin = new Thickness(10, 0, 0, 0),
};
vStackLayout.Children.Add(lblItemLabel8);
var entry8 = new Entry
{
//HorizontalOptions = LayoutOptions.Fill,
MinimumWidthRequest = 300,
Margin = new Thickness(20, 0, 15, 15),
};
vStackLayout.Children.Add(entry8);
vScrollView.Content = vStackLayout;
Content = vScrollView;
}
}
}
をしかし、私はCarouselPageを作成し、子としての上記コンテンツページを追加するとき、キーボードはもはやビューを押し上げるません。代わりに、Entryフィールドをカバーします。
以下、動作しません:
public App()
{
InitializeComponent();
MainPage = new CarouselPage1();
}
namespace App2
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CarouselPage1 : CarouselPage
{
public CarouselPage1()
{
InitializeComponent();
var page = new MainPage1(); //Same exact MainPage1 as in first code block above.
this.Children.Add(page);
}
}
}
がどのように私はキーボードがCarouselPageを使用しているとき、私のエントリフィールドをカバーしていないことで正常に動作するのですか?
誰でも?キーボードが表示されたときにページの変更を認識することはできません。 Page.Heightの変更メソッドまたはPage.LayoutChangeメソッドを使用しようとしましたが、キーボードが表示されたときに変更が認識されませんでした。どのように私は回避策をコード化することができます誰もが任意のアイデアを持っていますか?私はWindowsとiOSの両方を打つ必要があります。 – Stacy