Vic*_*ent 17 android scroll android-layout android-studio android-recyclerview
在过去的几周里,我一直在学习如何使用RecyclerView.我需要实现一个水平列表,即通过以横向模式转动设备,如下所示:
我发现这个(如何创建的水平位移的最佳解决方案RecyclerView,在这里),却遇到了另一个问题.该项目RecyclerView大于设备的高度(横向,水平),因此我需要同时创建垂直和水平位移.
我查看了LayoutManager该类的Android Developer方法,但我的技能不够高,无法理解大多数方法.我也尝试将所有内容RecyclerView垂直放在另一个内部RecyclerView,但是我收到错误:
IllegalStateException:RecyclerView没有LayoutManager
为了重新考虑这一点,我删除<View ... />了XML文件中的所有元素,但这并没有给出任何结果.
澄清我的问题:是否可以让我的布局水平和垂直滚动,如果你能解释我将如何欣赏它.
Vic*_*ent 17
我对那些没有考虑过最简单解决方案的应用程序所遇到的所有问题感到非常生气.
在一个RecyclerView由两个XML文件组成的文件中,主要用于声明RecyclerView,另一个用于内容.
最简单的解决方案是引入RecyclerViewa ScrollView.所以我可以一次移动所有项目,因为ScrollView垂直和水平我可以移动项目,这要归功于RecyclerView横向模式.
activity_main.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/cardIn_margin_ext">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarStyle="outsideInset"
android:scrollbars="horizontal" />
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
小智 9
接受的答案对我不起作用。我不得不使用 HorizontalScrollView 而不是简单的 ScrollView。
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/cardIn_margin_ext">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarStyle="outsideInset"
android:scrollbars="horizontal" />
</HorizontalScrollView >
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12263 次 |
| 最近记录: |