【问题标题】:EditText is hidden by the keyboardEditText 被键盘隐藏
【发布时间】:2019-10-15 21:38:06
【问题描述】:

我的应用程序是一个选项卡式应用程序。 对于保留主要片段的片段,我使用了 FrameLayout:

  <FrameLayout
    android:id="@+id/actualtabcontent"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:layout_above="@+id/tabContainer"
    android:background="@color/white"/>

每个新片段都是使用 LinearLayout 创建的,并且在需要时,我在 LinearLayout 中使用了 ScrollView。 问题是,当我的布局很大并且屏幕底部有 EditText 时,键盘在 EditText 上方打开,我再也看不到它了。

我试图在我的清单文件中添加这个:

 android:windowSoftInputMode="----"

所有可能的组合,直到现在都没有任何效果。

另外,我添加了

android:fitsSystemWindows="true

在 FrameLayout 中,这是我所有片段的父级,而且它也不起作用。

我希望,当键盘打开时,视图会滚动,以便将焦点 EditText 放在键盘顶部。

【问题讨论】:

    标签: android xamarin.android android-edittext android-framelayout


    【解决方案1】:

    问题是 MainActivity 的所有属性都不在清单文件中,它们作为属性添加到 View 类中,因为我使用的是 Xamarin.Android。

    到目前为止我添加的所有规则都已添加到另一个活动中。

    【讨论】:

    • 谢谢分享,可以标记一下。这将使答案搜索更容易,对社区成员有益。
    【解决方案2】:

    您将windowSoftInputMode 分配为“----”,

    这是造成问题

    尝试添加这个

    android:windowSoftInputMode="stateHidden|adjustPan" 
    

    在您正在使用的活动的清单文件中

    类似的东西

    <activity
        android:name=".MainActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize|stateHidden" >
    </activity>
    

    【讨论】:

    • "----" 只是一个占位符,以强调我将它与许多组合一起使用。
    • 请尝试以上组合,如果有效,请告诉我
    • 您能否显示包含 EditText 的 XML 文件?
    • 你把这行android:windowSoftInputMode="stateHidden|adjustPan" 放在清单文件的什么地方?
    【解决方案3】:

    在您的清单中将其放入您的特定活动中:

    android:windowSoftInputMode="adjustPan" 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-07
      • 1970-01-01
      • 2013-08-20
      • 2013-01-12
      • 1970-01-01
      • 2014-12-13
      相关资源
      最近更新 更多