Android 单击“下一步”按钮时,将焦点移动到EditText的右侧

Android 单击“下一步”按钮时,将焦点移动到EditText的右侧,android,android-layout,Android,Android Layout,我需要把焦点转到右边的编辑文本。我已经给出了android:nextFocusRight的但是。它不会移动到山脊一侧。取而代之的是将焦点移到下方 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="false" android:orientation="h

我需要把焦点转到右边的编辑文本。我已经给出了android:nextFocusRight的
但是。它不会移动到山脊一侧。取而代之的是将焦点移到下方

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:nextFocusRight="@id/edt2"
            android:inputType="text"
            android:singleLine="true" />

        <EditText
            android:id="@+id/edt2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true" />

    </LinearLayout>

在您的
edt1
编辑文本中尝试使用android:imeOptions=“actionNext”
,它会起作用

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:imeOptions="actionNext"
            android:nextFocusRight="@+id/edt2"
            android:inputType="text"
            android:singleLine="true" />

        <EditText
            android:id="@+id/edt2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true" />

    </LinearLayout>

您只需使用属性“nextFocusDown”而不是“nextFocusRight”即可解决您的问题

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:inputType="text"
            android:nextFocusDown="@id/edt2"
            android:singleLine="true" />

        <EditText
            android:id="@+id/edt2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true" />

    </LinearLayout>