Ján*_*nos 5 android android-layout android-recyclerview
RecyclerView以垂直方向显示,并且无法设置此属性,因为方向属于LinearLayoutManager对象.有什么方法可以模拟HORIZONTAL布局?
无论如何,linearLayoutManager在代码中创建的设置为HORIZONTAL.
llm.setOrientation(LinearLayoutManager.HORIZONTAL);
Run Code Online (Sandbox Code Playgroud)
Chr*_*n D 18
尝试将这些参数添加到布局xml中的RecyclerView:
android:orientation="horizontal"
android:scrollbars="horizontal"
app:layoutManager="LinearLayoutManager"
Run Code Online (Sandbox Code Playgroud)
AFAIK,还没有这样的设施编辑器提供。尽管您可以在运行时设置 Horizontal 的方向LinearLayoutManager,但这将满足您的要求。
LinearLayoutManager layoutManager
= new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
Run Code Online (Sandbox Code Playgroud)