Android 电视键盘盖文本字段

发布于 2025-01-13 16:56:35 字数 5501 浏览 8 评论 0原文

您好,我正在使用 flutter 开发 android 电视应用程序,但我面临一些问题,如果文本字段太多,键盘将覆盖文本字段。我已经将 SingleScrollview 添加到容器中,但似乎键盘不会向上推文本字段。有什么建议吗?感谢

附上手机截图 输入图片此处描述

这是我的代码 主dart

 @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomInset: true,
        body: SingleChildScrollView(
          physics: ClampingScrollPhysics(),
          child: Container(
            child: ListView(
              shrinkWrap: true,
              physics: ClampingScrollPhysics(),
              children: <Widget>[
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                )
              ],
            ),
          ),
        ));
  }

AndroidManifest.xml

     
   <application
        android:label="mysing"
        android:banner="@drawable/banner"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustPan">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                  <action android:name="android.intent.action.MAIN"/>
                    <category  android:name="android.intent.category.LEANBACK_LAUNCHER"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>

Hi I am developing android tv app by using flutter, But I face some problem that keyboard will cover the textfield if the textfield are too many.I already add the SingleScrollview to the container, but seem like keyboard wont push up the textfield. Any suggestion? Thanks

Attach of mobile screenshot
enter image description here

Here is my code
Main.dart

 @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomInset: true,
        body: SingleChildScrollView(
          physics: ClampingScrollPhysics(),
          child: Container(
            child: ListView(
              shrinkWrap: true,
              physics: ClampingScrollPhysics(),
              children: <Widget>[
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                ),
                TextFormField(
                  decoration: InputDecoration(
                    labelText: 'Enter Text',
                  ),
                )
              ],
            ),
          ),
        ));
  }

AndroidManifest.xml

     
   <application
        android:label="mysing"
        android:banner="@drawable/banner"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustPan">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                  <action android:name="android.intent.action.MAIN"/>
                    <category  android:name="android.intent.category.LEANBACK_LAUNCHER"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文