首页 > 解决方案 > 如何修复“TextInputLaout 与 TextInputEditText 视图我无法使用 imeOption 和 nextFocustDown 属性显示下一个焦点 Edittext”

问题描述

我使用 EditText imeOption 效果很好。但是当我在 TextInputEditText 中使用 TextInputLayout 时,我看到了很多资源并在我的代码中实现它但是我无法得到我想要的实际结果。

   <!--mobile number input layout -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_vertical"
        android:focusable="true"
        android:focusableInTouchMode="true">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/ic_call_24px"/>

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:backgroundTint="@color/grey_text_color"
            android:layout_marginLeft="@dimen/base_padding_small">

            <android.support.design.widget.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/etMobileNo"
                android:inputType="textNoSuggestions"
                android:hint="Mobile No"
                android:singleLine="true"
                android:paddingBottom="26dp"
                android:backgroundTint="@color/grey_text_color"
                android:textSize="18sp"
                android:maxLines="1"
                android:nextFocusDown="@+id/etPassword"
                android:imeOptions="actionNext"
                android:textColor="@color/grey_text_color"
                android:textColorHint="@color/grey_text_color"/>
        </android.support.design.widget.TextInputLayout>

    </LinearLayout>

    <!--Password input layout-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_vertical"
        android:focusable="true"
        android:focusableInTouchMode="true">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/ic_lock_24px"/>

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:passwordToggleContentDescription=""
            app:passwordToggleDrawable="@drawable/visibility_toggle_button"
            app:passwordToggleEnabled="true"
            app:passwordToggleTint="@color/grey_text_color"
            android:layout_marginLeft="@dimen/base_padding_small"
            android:backgroundTint="@color/grey_text_color">

            <android.support.design.widget.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/etPassword"
                android:hint="Password"
                android:inputType="textPassword"
                android:paddingBottom="26dp"
                android:maxLines="1"
                android:backgroundTint="@color/grey_text_color"
                android:textSize="18sp"
                android:imeOptions="actionDone"
                android:textColor="@color/grey_text_color"
                android:textColorHint="@color/grey_text_color"/>
        </android.support.design.widget.TextInputLayout>

    </LinearLayout>

我确实帮助了这个参考,但没有工作。 Android EditText 下一个焦点

没有java代码我怎么能使用,在此先感谢。

标签: androidandroid-edittextandroid-textinputlayoutandroid-textinputedittext

解决方案


尝试使用

android:imeOptions="actionNext"
android:nextFocusForward="@+id/etPassword"

代替:

 android:nextFocusDown="@+id/etPassword"
 android:imeOptions="actionNext"

推荐阅读