当文本字段成为焦点时,则内容在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清单中应该包含以下内容:

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

10-06 08:02