在我Activity
我初始化Fragment
,其中包含了RecyclerView
的所有項目。但我意識到它沒有顯示所有項目。這意味着,而不是14它只顯示11項。除了最後一個可見項目(編號12)板缺掉
我實現
的Activity
包含空FrameLayout
充當Fragment
容器:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res./android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e0e0e0">
<LinearLayout
android:id="@+id/layout_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/layout_border_white"
android:paddingBottom="@dimen/footer_padding">
<include layout="@layout/footer"></include>
</LinearLayout>
<FrameLayout
android:id="@+id/fragment_start"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/layout_footer"/>
</RelativeLayout>
這裏是RecyclerView在片段中:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e0e0e0"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layout_header"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:padding="@dimen/startpage_padding"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<include layout="@layout/header"></include>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/startpage_margin"
android:scrollbars="vertical"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layout_header"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ProgressBar
android:id="@+id/pb_loading_indicator"
android:layout_width="@dimen/startpage_progressbar"
android:layout_height="@dimen/startpage_progressbar"
android:visibility="invisible"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/tv_error_message_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:padding="@dimen/startpage_text_padding"
android:text="@string/error_message"
android:textSize="@dimen/startpage_text"
android:visibility="invisible"/>
</LinearLayout>
解決途徑
我已經與match_parent
試過在RecyclerView
,並還增加了一個paddingBottom
它。用paddingBottom =「30dp」可以看到更多的元素,但這不是一個好的解決方案。此外,我的Activity
正在使用AlertDialog
-設置在Manifest
中的主題。刪除它顯示相同的結果。
任何幫助將不勝感激。
變化'機器人:layout_above = 「@ ID/layout_footer」'到'機器人:layout_above = 「@ + ID/layout_footer」'還有爲什麼你使用'應用:layout_constraintTop_toBottomOf = 「@ + ID/layout_header」 'RecyclerView' – Piyush
感謝提示,但沒有幫助。我使用'app:layout_constraintTop_toBottomOf =「@ + id/layout_header」'進行定位,因爲'RecyclerView'位於'ConstraintLayout'中。 –
RecyclerView的父視圖是什麼? –