我不知道为什么,但是即使我在代码和xml布局中设置了布局参数,我片段中的布局或内容也无法填充父项。有谁对此有解决方案。提前致谢。 我的片段的图像如下。
显示的图像是用recyclerview完成的 recyclerview。 XML文件 fragment_items。 XML文件 ItemsFragment的onCreateView。 Java类
答案 0 :(得分:0)
ConstraintLayout
允许您创建具有平面视图层次结构(无嵌套视图组)的大型复杂布局。
您的RecyclerView将是(尊重ConstraintLayout)
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
>
答案 1 :(得分:0)
如果您只在fragment_items中包含recyclerview,则可以使用
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_videos"
android:layout_height="match_parent"
android:layout_width="match_parent"
/>
</LinearLayout>