【问题标题】:Android Soft Keyboard freezes visible layout until closedAndroid软键盘冻结可见布局直到关闭
【发布时间】:2014-12-10 20:49:19
【问题描述】:

我在LinearLayout 里面有一堆EditTextScrollView 里面。当我点击其中一个时,软键盘正常出现,我的EditText 出现焦点。但是当我输入时,文本没有显示出来。甚至没有显示光标。当我点击另一个EditText 或应进行可见更改(添加视图)的按钮时,或单击键盘上的下一步时,视觉上没有任何变化。但是一旦我关闭键盘(使用后退按钮或以编程方式),我终于可以看到变化:出现键入的文本并选择了所需的EditText

好像一切正​​常,只有屏幕被冻结,直到我关闭软输入,然后我才能看到进度。

为什么会发生这种情况,我该如何解决? 以编程方式关闭键盘无法通过,因为我需要键盘上的 Next 按钮才能工作,并且不断打开/关闭使我的 UI 看起来很混乱。

我的EditText都是这样的,只是ID和Hint不同而已。

<EditText
    android:id="@+id/dataFullName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:hint="Personal name"
    android:inputType="textNoSuggestions|textPersonName|textVisiblePassword"
    android:textColor="#FFFFFF" />

这是ScrollView 拿着LinearLayout 拿着我的EditText

<ScrollView
    android:id="@+id/generalsScrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >


        <!-- my EditText's here -->


        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:text="Additional information:"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@android:color/white"
            android:textSize="@dimen/additional_text" />

        <LinearLayout
            android:id="@+id/generalsContainer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/additional_margin"
            android:orientation="vertical" >
        </LinearLayout>

        <LinearLayout
            android:id="@+id/generalsAdder"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <Button
                android:id="@+id/newGeneralButton"
                android:layout_width="96dp"
                android:layout_height="32dp"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:background="@drawable/bttn_bg"
                android:onClick="newGeneralButtonPressed"
                android:text="Add"
                android:textColor="@android:color/white"
                android:textColorHint="@android:color/white"
                android:textColorLink="@android:color/white" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>

【问题讨论】:

  • 感谢您在我面前面对这个问题并提出问题和答案。让我试试你的方法..

标签: android android-layout keyboard android-edittext


【解决方案1】:

我刚刚又解决了我的问题。在同一个 LinearLayout 中有太多的 EditText。所以我只是把它们分成2个LinearLayout,现在很好。有谁知道为什么会这样?

【讨论】:

  • 它没有帮助。我只有两个EditTexts。同样对我来说,当EditText 靠近手机底部并且键盘必须将它们移动到顶部以显示在键盘上方时,就会出现这个问题。当EditText 已经在顶部并且键盘外观没有任何变化时,它不会出现。此外,这只发生在 Android 9 中,而不是以前的版本。
【解决方案2】:

对我来说,问题只出在 Android 9 Pie 中,通过设置 android:hardwareAccelerated="true" 得到了解决。

Here 是对该解决方案的引用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-22
    • 2023-03-07
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    • 2016-07-15
    • 2011-11-17
    • 2016-04-20
    相关资源
    最近更新 更多