Ali*_*ani 5 android android-recyclerview
我有一个RecyclerView在StaggeredGridLayoutManager 里面ScrollView.由于你不能设置WRAP_CONTENT参数RecylerView(不支持它),我必须动态地计算视图的高度.(适配器动态填充.它是一个无限的滚动视图).您可以在Pinterest应用程序中找到类似的行为.(如下图).我还编写了布局视图层次结构.
<ScrollView>
<LinearLayout>
<some_layouts>
.
.
</some_layouts>
<RecyclerView>
</RecyclerView>
<LinearLayout>
<ScrollView>
Run Code Online (Sandbox Code Playgroud)
如何才能在我的应用程序中获得相同的功能?我在课程api中挖掘但没有发现任何东西.谁可以帮我这个事?

尽管答案为时已晚,而且我也在找到解决方案,但我遇到了该库,其中项目布局的大小可以通过几行代码动态调整。
只需添加
dependencies {
implementation 'com.google.android:flexbox:0.3.2'
}
Run Code Online (Sandbox Code Playgroud)
使用下面的代码:-
FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(getContext());
layoutManager.setFlexWrap(FlexWrap.WRAP);
recyclerView.setLayoutManager(layoutManager);
Run Code Online (Sandbox Code Playgroud)
所以你没有动态计算高度。
| 归档时间: |
|
| 查看次数: |
717 次 |
| 最近记录: |