微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – RecyclerView切断最后一项

我们可以看到这里最后一项是部分可见的.我怎样才能解决这个问题?
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>

解决方法

@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"/>

原文地址:https://www.jb51.cc/android/316706.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐