Android Keyboard hides EditText

社会主义新天地 提交于 2019-11-28 06:14:23

In your manifest put this in your perticular activity:

 android:windowSoftInputMode="adjustPan" 

For that you have to declared in your activity manifeast

         <activity
            android:name=".activityname"
            android:label="@string/app_name"
            android:windowSoftInputMode="adjustPan|adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

Declare windowSoftInputMode="adjustResize" in manifest.xml file

<activity
        android:name=".example"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="adjustResize" />

provide scroll view to the xml layout file

<RelativeLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         xmlns:tools="http://schemas.android.com/tools"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:paddingBottom="16dp"
         android:paddingLeft="16dp"
         android:paddingRight="16dp"
         android:paddingTop="16dp"
         android:fitsSystemWindows="true">

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:isScrollContainer="false">

   // add edittext here...

 </ScrollView>
 </RelativeLayout>

Here is simple solution for Android EditText issue of hiding behind SoftKeypad. Use the code in AndroidManifest.xml file of the project module.

<activity
        android:name="com.example.MainActivity"
        android:label="@string/activity_main"
        android:windowSoftInputMode="adjustResize|stateHidden" />

This code worked for me.
Inside the manifest file in activity tag add this attribute:

android:windowSoftInputMode="adjustResize|stateHidden"

There are more such values for this attribute (android:windowSoftInputMode) which will come as recommendation list. You can check with them also.

Use the below code where:

InputMethodManager ipmm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                ipmm.hideSoftInputFromWindow(url.getWindowToken(), 0);

where url in my code is:

url = (EditText) findViewById(R.id.eT_webbrowser);

or Try this:

InputMethodManager ipmm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                    ipmm.hideSoftInputFromWindow(null, 0);

As another option try this: This always hides the soft input mode such that your EditText is visible

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

The solution for me was, simply, adding this to the parent layout : android:fitsSystemWindows="true"

This seems to be a bug in android when adjustPan mode is set

Try this Custom EditText with workaround for this problem

https://gist.github.com/Arjun-sna/768de4ca141798c59a8166a2e5d4a743

In your AndroidManifest.xml add adjustPane in the activity tag

<activity android:name=".LoginActivity"
          android:windowSoftInputMode="adjustPan"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!