I created this custom view extended from AppCompatEditText :
public class NoteEditText extends AppCompatEditText {
// INTERFACES ----------------------------------------------------------------------------------------------------
public interface OnKeyPreImeListener {
void onKeyPreIme(int keyCode, KeyEvent event);
}
// ATTRIBUTES ----------------------------------------------------------------------------------------------------
private MovementMethod movementMethod;
private KeyListener keyListener;
private OnKeyPreImeListener onKeyPreImeListener;
// CONSTRUCTORS ----------------------------------------------------------------------------------------------------
public NoteEditText(Context context) {
super(context);
this.movementMethod = this.getMovementMethod();
this.keyListener = this.getKeyListener();
}
public NoteEditText(Context context, AttributeSet attrs) {
super(context, attrs);
this.movementMethod = this.getMovementMethod();
this.keyListener = this.getKeyListener();
}
public NoteEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.movementMethod = this.getMovementMethod();
this.keyListener = this.getKeyListener();
}
// SETTERS ----------------------------------------------------------------------------------------------------
public void setOnKeyPreImeListener(OnKeyPreImeListener onKeyPreImeListener) {
this.onKeyPreImeListener = onKeyPreImeListener;
}
// METHODS ----------------------------------------------------------------------------------------------------
public void enable() {
this.setMovementMethod(this.movementMethod);
this.setKeyListener(this.keyListener);
this.setFocusableInTouchMode(true);
this.setImeOptions(EditorInfo.IME_ACTION_DONE);
this.setRawInputType(InputType.TYPE_CLASS_TEXT);
}
public void disable() {
this.setMovementMethod(null);
this.setKeyListener(null);
}
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (this.onKeyPreImeListener != null)
this.onKeyPreImeListener.onKeyPreIme(keyCode, event);
return true;
}
}
I call it like this :
<com.company.adapters.items.NoteEditText
android:id="@+id/note"
style="@style/AppTheme.SubItem"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_margin_xs"
android:gravity="center_vertical"
android:hint=""
android:imeOptions="actionDone"
android:inputType="textMultiLine|textCapSentences|textNoSuggestions"
android:minHeight="@dimen/content_subitem_height"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/note_icon"
app:layout_constraintTop_toBottomOf="@+id/name" />
It works well, except the "textMultiLine|textCapSentences|textNoSuggestions" inputTypes. Neither "textCapSentences" nor "textNoSuggestions" are applied, although "textMultiLine" is working.
If I use the exact same configuration but with the original EditText view, all the inputTypes work... very strange.
this.setRawInputType(InputType.TYPE_CLASS_TEXT);
From your enable function. This is overriding the input type.