如何更改 xml 中回收器视图的方向?

Net*_*eru 2 android kotlin

我有 2 个回收者视图。1 个水平和 1 个垂直。在设计页面中,第一个回收器的元素是水平的,第二个回收器的元素是垂直的,但是当我运行应用程序时,它们都是垂直的,我无法弄清楚问题是什么。

  <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/selected_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:orientation="horizontal"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/name_edit_text"
        tools:listItem="@layout/item_participant_selected" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="120dp"
        android:layout_marginBottom="@dimen/participants_padding_bottom"
        android:clipToPadding="false"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintEnd_toEndOf="@id/selected_recycler_view"
        app:layout_constraintStart_toStartOf="@id/selected_recycler_view"
        app:layout_constraintTop_toBottomOf="@id/selected_recycler_view"
        tools:listItem="@layout/item_participant" /> 
Run Code Online (Sandbox Code Playgroud)

Pra*_*mar 5

xml-

android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
Run Code Online (Sandbox Code Playgroud)

以编程方式 -

RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(layoutManager);
Run Code Online (Sandbox Code Playgroud)