简体   繁体   English

出现软键盘时隐藏的EditText

[英]Hidden EditText when soft keyboard appears

I have this typical issue when soft keyboard appears for user to enter input and covers the EditText where text should appear. 当出现软键盘供用户输入输入并覆盖应出现文本的EditText时,我遇到了一个典型的问题。

I tried many different "fixes" and solution without success. 我尝试了许多不同的“修复”和解决方案,但均未成功。 I guess there is certain combination in my layout that causes this issue. 我猜我的布局中有某种组合会导致此问题。

Right now in AndroidManifest.xml I have this line 现在在AndroidManifest.xml中,我有这行

<activity       
    android:screenOrientation="landscape"
    android:windowSoftInputMode="adjustPan">

The layout with the EditText is as follows witht he EditText at bottom EditText的布局如下,底部是EditText。

<?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:fillViewport="true"
    android:scrollbars = "vertical"
    android:windowSoftInputMode="adjustPan|adjustResize">

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

<RelativeLayout
    android:id="@+id/cargoRoot"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:numColumns="auto_fit"
    android:stretchMode="columnWidth" >  

    <LinearLayout
        android:layout_height="wrap_content" android:layout_width="600dp"
        android:orientation="vertical" >

        <TextView style="@style/smalltext" />

        <TextView
              android:id="@+id/arrivalEta"
              android:layout_height="wrap_content" android:layout_width="wrap_content" />

        <TextView
            android:text="@string/cargoComments"
            style="@style/smalltext" />

        <ScrollView android:id="@+id/scrollEditCargoComments"
                    android:layout_width="fill_parent"      android:layout_height="142dp"
                    android:scrollbars="vertical">
            <EditText
            android:id="@+id/editCargoComments"             
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:textSize="@dimen/text_normal"
            android:minLines="5"
            android:imeOptions="actionDone"
            android:imeActionLabel="@string/send"
            android:inputType="textNoSuggestions"  />
            </ScrollView>
        </LinearLayout> 
    </RelativeLayout>
</LinearLayout>

Other things worth commenting is that I have this EditText with visibility gone until certain points in the app where the user is prompted to enter comments. 其他值得评论的是,我的EditText的可见性消失了,直到应用程序中提示用户输入评论的某些点为止。 Then I change visibility to visible and when user taps on the text the soft keyboard appears. 然后,我将可见性更改为“可见”,并且当用户点击文本时,出现软键盘。 It appears hiding everything behind it. 似乎隐藏了所有内容。 No Resize or Pan operation is done. 没有调整大小或平移操作。

The view that holds the EditText is infalted code-behind and inserted inside another view inside a PopupWindow. 包含EditText的视图位于代码后面,并插入到PopupWindow内的另一个视图中。

So is like MainActivity > PopupWindow > ViewFlipper > EditText 所以就像MainActivity> PopupWindow> ViewFlipper> EditText

I wonder if either PopupWindow or ViewFlipper add some poison to soft keyboard management. 我想知道PopupWindow或ViewFlipper是否会给软键盘管理添加一些毒药。

Thanks in advance 提前致谢

Try this: 尝试这个:

android:windowSoftInputMode="adjustResize|adjustPan|stateHidden" android:windowSoftInputMode =“ adjustResize | adjustPan | stateHidden”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM