android - Flutter 键盘在 android 中隐藏文本字段,但在 iOS 中工作正常

标签 android ios flutter flutter-layout

当文本字段聚焦时,内容在 iOS 中向上滚动,但在 android 中不起作用。我是否需要更改小部件的层次结构或需要更改 AndroidManifest 文件中的某些配置?我也尝试过 Scaffold 的 resizeToAvoidBottomInset 和 resizeToAvoidBottomPadding 属性

Widget build(BuildContext context) {
return Scaffold(
  body: Container(
    margin: EdgeInsets.all(0.0),
    decoration: BoxDecoration(
      image: DecorationImage(
          image: AssetImage("assets/images/background.png"),
          fit: BoxFit.fill),
    ),
    child: Stack(
      children: <Widget>[
        Center(
          child: Padding(
            padding: const EdgeInsets.symmetric(horizontal: 16.0),
            child: signUpCardView,
          ),
        ),
        userLogin(bloc),
      ],
    ),
  ),
);

}
Widget get signUpCardView {
return SingleChildScrollView(
      child: Card(
    color: Colors.white,
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        Padding(
          padding: EdgeInsets.symmetric(vertical: 30.0),
          child: Center(
            child: Column(
              children: <Widget>[
                Text(
                  "${AppTranslations.of(context).text("signUp")}",
                  style: TextStyle(
                    color: AppColors.BUTTON_SECONDARY_BACKGROUND_COLOR,
                    fontFamily: customFontFamily,
                    fontSize: 30.0,
                  ),
                ),
                SizedBox(
                  width: 50,
                  height: 20,
                  child: Divider(
                    thickness: 4.0,
                    color: AppColors.BUTTON_SECONDARY_BACKGROUND_COLOR,
                  ),
                )
              ],
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 0.0),
          child: nameField(bloc),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 0.0),
          child: mobileField(bloc),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 0.0),
          child: emailField(bloc),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 0.0),
          child: passwordField(bloc),
        ),
        confirmPasswordField(bloc),
        Center(
          child: Padding(
            padding: const EdgeInsets.symmetric(vertical: 16.0),
            child: submitButton(bloc),
          ),
        ),
        Padding(
          padding: EdgeInsets.symmetric(vertical: 8.0),
          child: Center(
            child: Padding(
              padding: const EdgeInsets.only(bottom: 50.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text(
                    "${AppTranslations.of(context).text("alreadyHaveAnAccount")}?",
                    style: TextStyle(
                      color: Colors.grey.shade600,
                      fontFamily: customFontFamily,
                    ),
                  ),
                  InkWell(
                    onTap: () {
                      _openSignInScreen();
                    },
                    child: Text(
                      " ${AppTranslations.of(context).text("signIn")}",
                      style: TextStyle(
                        color: AppColors.BUTTON_SECONDARY_BACKGROUND_COLOR,
                        fontFamily: customFontFamily,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ],
    ),
  ),
);

}

This is the UI

最佳答案

要使屏幕“调整大小”,即移动到光标,您的 android list 中应该包含以下内容:

<application
  ...
  <activity
    ...
    android:windowSoftInputMode="adjustResize"

关于android - Flutter 键盘在 android 中隐藏文本字段,但在 iOS 中工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61227116/

相关文章:

java - googleMap 上的 addmarker 和 markeroptions 的空指针异常

android - 如何设置文本右侧的复选框

ios - setInt 和 getInt 值改变 Flutter

flutter - 用=> 启动flutter 时如何调用多条语句?

flutter - 在AppBar上导致错误地存在于不同页面上

android - Google Play 服务 - 清除允许的帐户

java - Android:onTouchEvent 中断

ios - 在彼此之上的相同 View 之间交叉淡入淡出

ios - 音频播放完毕后播放计时器更新时的SwiftUI更新按钮标签

iphone - HTML 分页