【问题标题】:padding Soft input resize adjust in xamarin android在xamarin android中填充软输入调整大小
【发布时间】:2019-07-11 00:54:32
【问题描述】:

当出现软输入时,我正在尝试在 xamarin android 上调整屏幕大小。 但我的问题是我想在调整大小模式下为我的视图设置填充。 例如,当软输入出现时,我希望我的视图从顶部开始有 10 个填充。但它填满了我的屏幕。 我通过 loadApplication 方法使用此代码

        Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>()
            .UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);

【问题讨论】:

    标签: android xamarin xamarin.forms xamarin.android window-soft-input-mode


    【解决方案1】:

    在您更改 softInputMethod 时未触发任何事件。但是有这样的解决方法来处理全局布局更改

                FrameLayout content = (FrameLayout)activity.FindViewById(Android.Resource.Id.Content);
                mChildOfContent = content.GetChildAt(0);
                ViewTreeObserver vto = mChildOfContent.ViewTreeObserver;
                vto.GlobalLayout += (object sender, EventArgs e) => {
                //do whatever you want!
                //possiblyResizeChildOfContent();
                };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-04
      • 2012-08-14
      • 1970-01-01
      • 2015-07-08
      • 2022-01-09
      • 2011-01-03
      • 2011-10-09
      • 1970-01-01
      相关资源
      最近更新 更多