2016-09-04 92 views

回答

0

設置在主要活動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;