0
我想要一個按鈕始終在虛擬鍵盤上。爲此,我需要知道鍵盤的高度。我如何在XF中做到這一點?如何確定虛擬鍵盤高度?
我想要一個按鈕始終在虛擬鍵盤上。爲此,我需要知道鍵盤的高度。我如何在XF中做到這一點?如何確定虛擬鍵盤高度?
設置在主要活動WindowSoftInputMode = SoftInput.AdjustResize
並使用此代碼工作:)
public Page1()
{
InitializeComponent();
var al = new AbsoluteLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
var button = new BoxView {Color = Color.Red, VerticalOptions = LayoutOptions.FillAndExpand};
var entry = new Entry {HorizontalOptions = LayoutOptions.Fill};
al.Children.Add(button, new Rectangle(0, App.Dimensions.Height - 120, App.Dimensions.Width, 120));
al.Children.Add(entry, new Rectangle(10, 50, 200, 60));
Content = al;
Content.SizeChanged += (sender, args) =>
{
button.Layout(new Rectangle(0, Content.Height - 120, App.Dimensions.Width, 120));
};
}
App.Dimensions
在MainActivity評價是這樣的:
DisplayMetrics displayMetrics = Resources.DisplayMetrics;
App.Dimensions.Height = displayMetrics.HeightPixels/displayMetrics.Density;
App.Dimensions.Width = displayMetrics.WidthPixels/displayMetrics.Density;