Giovani Gonzalez
Giovani Gonzalez

Reputation: 3

ImeOption DONE not working when EditText is inside Cardview

The EditText imeOption is not working when is Inside of CardView, I tried different options like adding the imeOption in code with:

editPassword.setImeOptions(EditorInfo.IME_ACTION_DONE);

The XML that I'm using is:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical">

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/normal_padding_screen"
            android:layout_marginEnd="@dimen/normal_padding_screen"
            app:cardBackgroundColor="@android:color/white"
            app:cardElevation="6dp">

            <EditText
                android:id="@+id/editTextEmail"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/white"
                android:padding="8dp"
                android:hint="@string/hint_email"
                android:imeOptions="actionNext"
                android:inputType="textEmailAddress"
                android:drawableStart="@drawable/ic_mail"
                android:drawablePadding="8dp"/>
        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginStart="@dimen/normal_padding_screen"
            android:layout_marginEnd="@dimen/normal_padding_screen"
            android:layout_marginBottom="10dp"
            android:descendantFocusability="beforeDescendants"
            app:cardBackgroundColor="@android:color/white"
            app:cardElevation="6dp">

            <EditText
                android:id="@+id/editTextPass"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/white"
                android:padding="8dp"
                android:lines="1"
                android:imeOptions="actionDone"
                android:hint="@string/hint_password"
                android:drawableStart="@drawable/ic_password"
                android:drawablePadding="12dp"/>
        </android.support.v7.widget.CardView>

    </LinearLayout>

but still with the imeOption set as "actionDone" in EditText for Password in the keyboard I see the option of "Enter/next_line"

screenshot

Upvotes: 0

Views: 924

Answers (1)

Bawender Yandra
Bawender Yandra

Reputation: 210

You seem to have missed some of the required parameters for the EditText. Add maxlines="1", which restricts it to single line. Add inputType ="textPassword" or "numberPassword", which defines the input type of the EditText. With these two values your EditText should be working fine.

           <EditText
            android:id="@+id/editTextPass"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:padding="8dp"
            android:maxLines="1"
            android:inputType="textPassword"
            android:imeOptions="actionDone"
            android:hint="enter password"
            android:drawableStart="@mipmap/ic_launcher"
            android:drawablePadding="12dp"/>

Hope this helps you. Happy Coding.

Upvotes: 1

Related Questions