How to add margin between EditText and Soft Keyboard? How to add margin between EditText and Soft Keyboard? android android

How to add margin between EditText and Soft Keyboard?


I find the attribute of paddingBottom can effect the distance between the editText and the keyboard. You can do like this:

<RelativeLayout     android:layout_width="match_parent"     android:layout_height="110dp">   <ImageView     android:layout_width="match_parent"     android:layout_height="100dp"     android:background="@drawable/your_edit_text_background"/>     <EditText     android:layout_width="match_parent"     android:layout_height="match_parent"     android:paddingBottom="10dp"/> </RelativeLayout>

This will make your keyboard margin your EditText by 10dp


This seems to work, though has some unwanted effect on the layout.

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

If anybody knows how to get this working with ADJUST_PAN, that would be great!


Try to add your RelativeLayout in ScrollView, and then add code below:

editTextField.setOnFocusChangeListener(new OnFocusChangeListener() {    @Override    public void onFocusChange(View v, boolean hasFocus) {        // TODO Auto-generated method stub        if (hasFocus)             scrollView.scrollBy(0, 150);    });