我们可以看到这里最后一项是部分可见的。我怎样才能解决这个问题? layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
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="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include
layout="@layout/header"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/grey_background">
<ImageView
android:id="@+id/image"
android:layout_width="@dimen/thumbnail_width"
android:layout_height="@dimen/thumbnail_height"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitCenter"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/image"
android:orientation="vertical"
android:padding="@dimen/participant_left_padding">
<TextView
android:id="@+id/participants_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:textColor="@android:color/white"/>
<TextView
android:id="@+id/total_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="view"
android:textColor="@android:color/white"/>
<TextView
android:id="@+id/ranking"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ranking"
android:textColor="@android:color/white"/>
</LinearLayout>
<ImageView
android:id="@+id/overflow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_action_overflow"/>
</RelativeLayout>
我也有同样的问题。在我看来,这是因为您设置了AppBarLayout XML属性android:fitsSystemWindows =“true”。为了解决这个问题,我给RecyclerView边距底部等于动作条尺寸
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/recyclerView"
android:layout_marginBottom="?attr/actionBarSize">
@Lester是对的问题是RecyclerView的wrap_content高度。但是改变match_parent是行不通的,因为。这个布局被添加到一个片段中,该片段被声明为wrap_content。所以我已将片段的高度和recyclerview的高度更改为match_parent,现在问题已解决。
<fragment
android:id="@+id/fragment"
android:name="com.example.fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
我在RecyclerView
里面有一个ConstraintLayout
这个问题,我把我的recyclerview constriants改为“0dp”(match_constraint)并且没有进一步的麻烦。
看一看
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- Title -->
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="@dimen/view_with_press_height"
android:text="@string/taxes_fees_charges"
android:gravity="center_vertical"
android:layout_marginStart="@dimen/general_side_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<!-- Details Recyclerview-->
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="@dimen/general_bottom_margin"
app:layout_constraintVertical_bias="0.0"
tools:itemCount="28"
tools:listitem="@layout/tax_details_row" />
</android.support.constraint.ConstraintLayout>
如果你想使用tools:itemCount="28"
,你必须在你的xmlns:tools="http://schemas.android.com/tools"
file中导入XML
。
使用RelativeLayout而不是ConstraintLayout.It对我有用。
对于其他人。在recyclerview中禁用嵌套滚动也会在CoordinatorLayout中导致此问题与可滚动工具栏或tablayout。因为滚动recyclerview时,工具栏或tablayout不会滚动。
我尝试了大多数可能的网站上的所有可用选项,但我没有得到解决方案。然后,我想我可以使用底部填充?是的,这对我有用。
我正在向你分享这些代码。除了高度,宽度和填充之外,不需要任何其他属性。
机器人: “ATTR / actionBarSize” paddingBottom来=
<android.support.v7.widget.RecyclerView
android:id="@+id/your id name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="?attr/actionBarSize"
app:layout_constraintTop_toBottomOf="@+id/your field" />