作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 2 个回收站 View 。 1 个水平和 1 个垂直。在设计页面中,第一个回收器的元素是水平的,第二个是垂直的,但是当我运行 then app 时,它们都是垂直的,我不知道是什么问题。
<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" />
最佳答案
XML-
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
以编程方式-
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(layoutManager);
关于android - 如何在 xml 中更改回收器 View 的方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59451656/
我是一名优秀的程序员,十分优秀!