我在RecyclerView
中有一个StaggeredGridLayoutManager
ScrollView
。由于无法为WRAP_CONTENT
设置RecylerView
参数(不支持),我必须动态计算视图的高度。 (适配器动态填充。它是一个无限的滚动视图)。您可以在 Pinterest 应用中找到类似的行为。 (如下图)。我还编写了布局视图层次结构。
<ScrollView>
<LinearLayout>
<some_layouts>
.
.
</some_layouts>
<RecyclerView>
</RecyclerView>
<LinearLayout>
<ScrollView>
如何才能在我的应用中获得同样的效果?我在课程api中挖掘但没有发现任何东西。任何人都可以帮我吗?
答案 0 :(得分:1)
虽然回答太晚了,但我也找到了解决方案,我遇到了一个库,其中项目布局的大小是用几行代码动态调整的。
添加
* Fill method structure
ls_methods-refnumber = 1.
ls_methods-method = 'SAVE'.
APPEND ls_methods TO lt_methods.
ls_methods-refnumber = 1.
ls_methods-objecttype = 'OBJECTLIST'.
ls_methods-method = 'CHANGE'.
ls_methods-objectkey = '000480000020'.
APPEND ls_methods TO lt_methods.
ls_methods-refnumber = 1.
ls_methods-objecttype = 'HEADER'.
ls_methods-method = 'CHANGE'.
ls_methods-objectkey = '000480000020'.
APPEND ls_methods TO lt_methods.
* Fill header structure
ls_header-orderid = '000480000020'.
ls_header-notif_no = '100000356980'.
APPEND ls_header TO lt_header.
* Fill header up structure
ls_header_up-orderid = '000480000020'.
ls_header_up-notif_no = '100000356980' .
APPEND ls_header_up TO lt_header_up.
* Fill object list structure
ls_object_list-notif_no = '100000356980'.
APPEND ls_object_list TO lt_object_list.
* Fill object list up structure
ls_object_list_up-processing_ind = 'X'.
APPEND ls_object_list_up TO lt_object_list_up.
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = lt_methods
it_header = lt_header
it_header_up = lt_header_up
it_objectlist = lt_object_list
it_objectlist_up = lt_object_list_up
return = lt_return .
使用以下代码: -
dependencies {
implementation 'com.google.android:flexbox:0.3.2'
}
所以你没有动态计算身高。