我使用最新版本的Xamarin Forms。我有一個帶有內容頁面的Carousel頁面。內容頁面有一個滾動視圖,該視圖具有包含一些標籤和輸入輸入的堆疊佈局。當我觸摸條目輸入文本時,鍵盤會覆蓋輸入框,因此我看不到我正在輸入的內容。Xamarin Forms PCL Carousel Page中的鍵盤覆蓋我的輸入字段
我已經在基本應用程序上使用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並添加上述內容頁將其作爲一個孩子,鍵盤不再推動的觀點了。相反,它涵蓋了輸入字段。
以下,不工作:
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