NextFocusRight фокусируется не справа, а вниз - PullRequest
0 голосов
/ 02 июля 2019

Я работаю над приложением с несколькими edittext. Когда edittext принимает всю ширину, nextfocusdown работает правильно. Но когда есть два edittext на одной высоте (каждый текст редактирования занимает половину ширины), я хочу перевести фокус с левого на правый. Но когда я пишу nextFocusRight="id/EDIT_RIGHT" в моем xml, фокус не идет вправо edittext, а переходит к edittext под левым.

enter image description here

    <!-- EDIT LEFT-->
    <EditText
        android:id="@+id/EDIT_LEFT"
        android:layout_width="165dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="10dp"
        android:hint="@string/edit_left_hint"
        android:nextFocusRight="@id/EDIT_RIGHT"
        tools:ignore="Autofill"/>

    <!-- EDIT RIGHT-->
    <EditText
        android:id="@+id/EDIT_RIGHT"
        android:layout_width="165dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:hint="@string/edit_right_hint"
        android:nextFocusDown="@id/EDIT_DOWN"
        tools:ignore="Autofill"/>

1 Ответ

2 голосов
/ 02 июля 2019

Вы должны использовать как это -

<!-- EDIT LEFT-->
    <EditText
        android:id="@+id/EDIT_LEFT"
        android:layout_width="165dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="10dp"
        android:hint="@string/edit_left_hint"
        android:imeOptions="actionNext"
        android:nextFocusRight="@+id/EDIT_RIGHT"
        tools:ignore="Autofill"/>

    <!-- EDIT RIGHT-->
    <EditText
        android:id="@+id/EDIT_RIGHT"
        android:layout_width="165dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:hint="@string/edit_rgiht_hint"
        android:imeOptions="actionNext"
        android:nextFocusDown="@id/EDIT_DOWN"
        tools:ignore="Autofill"/>

Вы должны использовать android: nextFocusRight = "@ + id / EDIT_RIGHT" вместо android: nextFocusRight = "@ id / EDIT_RIGHT", потому что вы используете этоотредактируйте текст перед его созданием и используйте imeOptions.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...