Android: Keyboard overlaps with the EditText (with printscreens)

I have tried your XML and yes you are right the problem occur.

To solve the problem I have written this line in my MainActivity.java hope this help to you,And put the layout XML in ScrollView.

Activity

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.temp);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

        final EditText time = (EditText)findViewById(R.id.timeET);
        time.setOnTouchListener(new OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
                time.requestLayout();
                MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);

                return false;
            }
        });
        final EditText date = (EditText)findViewById(R.id.dateET);
        date.setOnTouchListener(new OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
                time.requestLayout();
                MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);

                return false;
            }
        });
         }

And The XML is Like,

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android" 
  android:orientation="vertical" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" > 

        <ScrollView android:id="@+id/scrollView1"
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent" 
        android:weightSum="1">
---
---
---
        </ScrollView> 
</LinearLayout> 

Leave a Comment