xml - 如何使用 Recycler View 设置水平协调器布局
问题描述
我需要实现我的布局水平,但现在它是线性布局,我不知道我的错误在哪里,但我需要你的帮助来解决这个问题
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/card_view_recycler_list"
android:scrollbars="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>
解决方案
在您的 java 类中输入以下代码:
LinearLayoutManager lManager = new
LinearLayoutManager(getApplicationContext(),LinearLayoutManager.HORIZONTAL, false);
lManager.setOrientation(LinearLayoutManager.HORIZONTAL);
mRecyclerView.setLayoutManager(lManager);
推荐阅读
- sql - 在 Rails 数据库中存储和稍后访问 JSON 对象的最佳实践
- firebase - 为我的物理设备设置 Flutter Firebase 模拟器
- reactjs - 如何获取 React TimePicker 的值
- python - 我想在“pip install”上提供一个额外的选项
- delphi - 监控自定义 URL 协议消息 - Delphi
- swift - UILabel textInsets with attributesText
- permissions - 还有其他方法吗,我在marklogic中以优化的方式检查了用户的权限?
- java - NativeSearchQueryBuilder 按字符串和布尔值搜索
- docker - Docker + Nginx + EMQX
- windows-10 - Autohotkey 未加载 MS Teams