1

I am using Custom EditText for holding multiple lines of text with Send option in Soft keyboard. It working fine but my tab bar is moving to top along with the keyboard. i used following in my manifest file.

    android:windowSoftInputMode="adjustPan"
    android:windowSoftInputMode="adjustResize"

These are working fine for normal EditText. But failed, if i am using CustomEditText.

This is my xml:

 <com.sample.helpers.CustomEditText 
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:hint="Description"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:textSize="16dp"
        android:id="@+id/et_description"

        />

my custom EditText class:

public class CustomEditText extends EditText {



public CustomEditText(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
}

public CustomEditText(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
}

public CustomEditText(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // TODO Auto-generated constructor stub
}

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    InputConnection connection = super.onCreateInputConnection(outAttrs);
    int imeActions = outAttrs.imeOptions&EditorInfo.IME_MASK_ACTION;
    if ((imeActions&EditorInfo.IME_ACTION_NEXT) != 0) {
        // clear the existing action
        outAttrs.imeOptions ^= imeActions;
        // set the DONE action
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
    }
    if ((outAttrs.imeOptions&EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
        outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
    }
    return connection;
}

}

Screen shot :

enter image description here

So, please guide me how to handle this.

koti
  • 1,071
  • 3
  • 15
  • 35

1 Answers1

1

Try this in your Java code

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Anjali-Systematix
  • 1,531
  • 14
  • 17