【问题标题】:EditText is hidden by the softkeyboard in AndroidEditText 在 Android 中被软键盘隐藏
【发布时间】:2016-05-20 11:11:17
【问题描述】:

我在应用程序中有一个布局在编辑文本上具有视差效果,我的问题是**当我点击编辑文本软键盘时隐藏我的编辑文本?**有人可以帮我解决这个问题,我已经搜索并找到了关于在我的情况下不起作用的“WindowsoftInputmode”。

清单中的代码

<activity
            android:name="one.tusk.stush.activities.NewPostDetailActivity"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize|adjustPan" >

【问题讨论】:

  • 我试过了。它也不适用于我的情况。所以我删除了 android:windowSoftInputMode="adjustResize|adjustPan" 这一行然后它正在根据键盘调整我的布局
  • 请看我的回答...
  • @Dhiraj -bro 你能帮帮我吗?
  • @sulphuricAcid 实际上,如果您使用的是 android:windowSoftInputMode="adjustResize|adjustPan",这不应该发生,但我不知道为什么它会给出如此奇怪的行为
  • @sulphuricAcid 在阅读了你的 qi 之后尝试使用一个带有 android:windowSoftInputMode="adjustResize|adjustPan" 属性的编辑文本,但它在我的情况下也不起作用。所以我尝试删除这个属性并且它有效但是不知道为什么

标签: android android-edittext android-softkeyboard window-soft-input-mode


【解决方案1】:

您应该只使用android:windowSoftInputMode="adjustResize"

如果这还不够,您可能需要将属性 android:fitsSystemWindows="true" 添加到包含您的 EditText 的根布局中。

【讨论】:

    【解决方案2】:

    在你的清单中试试这个,

    <activity
            android:name=".rapcalsy.MainActivity"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    

    根据这个改变你的布局, 不要错过

    android:isScrollContainer="true"

     <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:isScrollContainer="true"
        android:orientation="vertical">
    
        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:background="#000000"
            android:padding="0dp"
            android:stretchColumns="*">
            ...
        </TableLayout>
    </ScrollView>
    

    【讨论】:

      【解决方案3】:

      请尝试一下。

      在 Manifest 中将 android:softInputMode 属性设置为 adjustResize,并将父布局放在 ScrollView 中。希望这会有所帮助。

      【讨论】:

        【解决方案4】:

        我按照你说的做了一些尝试,然后我得到了这个工作 编辑您的清单文件

            <activity
                        android:name="one.tusk.stush.activities.NewPostDetailActivity"
                        android:screenOrientation="portrait"
                        android:windowSoftInputMode="stateVisible" >
        

        然后在java类的oncreate中添加以下代码

         getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);  
        

        这样键盘就不会直接/始终显示给您

        【讨论】:

        • 但他的问题不在于隐藏或显示键盘。每当软键盘出现时,它都会隐藏他的编辑文本。
        • @jaydroider 在我的情况下它也没有隐藏editText
        猜你喜欢
        • 1970-01-01
        • 2012-02-18
        • 1970-01-01
        • 2012-10-30
        • 1970-01-01
        • 2014-08-07
        • 2014-12-13
        • 1970-01-01
        • 2013-08-20
        相关资源
        最近更新 更多