【问题标题】:android soft keyboard covers editText in landscapeandroid软键盘在横向覆盖editText
【发布时间】:2014-09-06 17:37:35
【问题描述】:

我有以下布局:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">

    <LinearLayout
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:orientation="vertical"
            android:layout_above="@+id/edittext">

        <TextView
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:text="line1"/>

        <TextView
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:text="line2"/>

        <TextView
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:text="line3"/>

    </LinearLayout>

    <EditText
            android:id="@id/edittext"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:layout_margin="5dp"
            android:text="test"
            android:layout_alignParentBottom="true"
            android:imeOptions="flagNoExtractUi"
            />
</RelativeLayout>

在 Nexus 上的横向视图中,它看起来像:

有没有办法解决这个问题,但保留标志 flagNoExtractUi ?

【问题讨论】:

标签: android android-edittext flags soft-keyboard


【解决方案1】:

在 Android 清单中定义 &lt;activity&gt;,如:

<activity android:name=".TodoEdit"
            android:windowSoftInputMode="adjustResize">

【讨论】:

  • 我已经这样做了,但它不起作用。查看我对问题的最后评论
  • 什么是标志 flagNoExtractUi,在 Android 中第一次听到。
  • 用于指定 IME 不需要显示其提取的文本 UI。对于可能是全屏的输入法,通常在横向模式下,这允许它们更小,并让部分应用程序显示在后面。尽管用户对应用程序的访问可能会受到限制,但它可以使(大部分)全屏 IME 的体验不那么刺耳。请注意,当指定此标志时,IME 可能无法设置为能够显示文本,因此仅应在不需要此标志的情况下使用它。
【解决方案2】:

您可以添加ScrollView,这样当键盘出现时,它会自动滚动以使视图完全可见。

【讨论】:

    【解决方案3】:

    这似乎是Android中的一个错误,但我找到了解决方案!只需将android:imeOptions="flagNoExtractUi" 替换为android:imeOptions="flagNoFullscreen",现在一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多