1

There's a problem that I can't find a solution to. When I launch my activity, the first time I select the EditText field, the keyboard works just fine ( it pans the layout ). When I minimize the keyboard and select it again, it overlaps the layout and the required EditText.

I've added android:windowSoftInputMode="adjustPan" to my androidManifest.xml, though it doesn't work.

Does anyone know how to fix this problem?

adelphus
  • 10,116
  • 5
  • 36
  • 46
Sw3das
  • 157
  • 1
  • 12
  • use this android:windowSoftInputMode="adjustResize|stateHidden" – kiran kumar Aug 27 '15 at 12:12
  • @kirankumar as I answered to maveroid, the adjustResize option still keeps my EditText overlapped under the keyboard – Sw3das Aug 27 '15 at 12:18
  • you should give a scroll view to your layout so that when the key board comes up you can scroll up this is what u need – kiran kumar Aug 27 '15 at 12:21
  • this is more like a workaround than a solution ;) – Sw3das Aug 27 '15 at 12:23
  • when adjustResize is given or else it is not given automatically android moves the edit text to some what top of the soft keyboard if this does not happens you should definetly use the scroll bar to fix the issue – kiran kumar Aug 27 '15 at 12:30
  • 1
    just for future reference: i had an issue similar to yours and the cause was a gravity="center" in the EditText. removed it and is working. guess it's just a bug from the OS (one more). – José Silva May 15 '17 at 17:30

3 Answers3

0

Please use android:windowSoftInputMode="stateVisible|adjustResize" in AndroidManifest.xml

maveroid
  • 1,840
  • 1
  • 20
  • 20
  • This didn't work, the EditText field still remains overlapped :/ – Sw3das Aug 27 '15 at 12:17
  • While this may solve the OP's problem, a few words of explanation will help the current and future readers to understand your answer even better. – Thom Aug 27 '15 at 13:39
0
Please check this simple and complete code and it works, i have tested it for you.

manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test22"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" 
            android:windowSoftInputMode="adjustPan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>


MainActivity:


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}


xml layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.test22.MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="62dp"
        android:layout_toRightOf="@+id/textView1"
        android:ems="10" >

        <requestFocus />
    </EditText>

</RelativeLayout>




Just copy it, it rocks 
Androider
  • 3,833
  • 2
  • 14
  • 24
0

One thing I've noticed is that a lot of people make the mistake of adding

android:windowSoftInputMode="stateVisible|adjustResize"

in their layout file, when in fact it needs to be in your AndroidManifest.xml activity definition.

<activity
        android:name=".user_interface.SettingsActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateVisible|adjustResize" />
Nathan F.
  • 3,250
  • 3
  • 35
  • 69