我在RecyclerView
内使用了ScrollView
。我在列表中设置了50个项目。但是RecyclerView
并未显示所有项目。屏幕上仅显示5个项目。请参阅here。
我的布局文件:
<android.support.v7.widget.RecyclerView
android:id="@+id/business_recycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:nestedScrollingEnabled="false"
android:isScrollContainer="false"
/>
我的Java课程:
bcontractor = new ArrayList<>();
badapter = new HomeBusinessAdapter(context, bcontractor);
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(context, 1);
mLayoutManager.setAutoMeasureEnabled(true);
businessdirList.setLayoutManager(mLayoutManager);
businessdirList.setItemAnimator(new DefaultItemAnimator());
businessdirList.setAdapter(badapter);
如何显示所有项目?
答案 0 :(得分:0)
可能的解决方案(我曾经遇到过和你一样的问题)
创建Recyclerview时,您需要为要显示的项目指定特定布局。检查xml并查看该布局的父级高度
您的scrollview的高度是否设置为与父级匹配?
答案 1 :(得分:0)
请勿在{{1}}中使用RecyclerView
,但在ScrollView
禁用NestedScrollView
&amp;的嵌套滚动时使用RecyclerView
另外,你应该将RecyclerView
高度设置为wrap_content
,这样它只需要采取它应该采取的,而不是只采取整个父高度。
因此,layout
应该是NestedScrollView->ViewGroupLayout->RecyclerView
答案 2 :(得分:0)
您可以使用https://android-developers.googleblog.com/2017/02/build-flexible-layouts-with.html
这里是示例:
添加此implementation 'com.google.android:flexbox:2.0.1'
到您的依赖项。
这是您的reyclerview配置:
val layoutManager = FlexboxLayoutManager(this)
layoutManager.flexDirection = FlexDirection.ROW
layoutManager.justifyContent = JustifyContent.FLEX_START
recyclerview.layoutManager = layoutManager
您也可以https://gist.github.com/siifii/3edd8cd2d4f5a9b4672b9976c0c55ff4
检查此要点答案 3 :(得分:0)
只需将SELECT
campaign,
(CASE WHEN event_date of buy > event_date of sale THEN "Error" ELSE "OK") AS Check_Date,
(CASE WHEN quantity of buy > quantity of sale THEN "Error" ELSE "OK") AS Check_Quantity
quantity
FROM sales;
替换为position:absolute
,然后将您的回收站视图body {
margin: 0;
}
#main {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: flex;
flex-direction: column;
background: red;
}
#header {
background: yellow;
}
#content {
background: gray;
flex: 1;
min-height: 0;
}
table {
width: 100%;
height: 100%;
background: blue;
color: white;
}
td {
position: relative;
}
video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
设置为<div id="main">
<div id="header">
Header
</div>
<div id="content">
<table>
<tr>
<td>
<video controls>
<source src="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/1080/Big_Buck_Bunny_1080_10s_1MB.mp4" type="video/mp4">
</video>
</td>
</tr>
</table>
</div>
</div>