Recycler view item fill up entire recycler view height after upgrading support library from “23.1.1” to “23.2.1”

后端 未结 7 2256
天命终不由人
天命终不由人 2020-12-24 06:28

Previously, I\'m using the following old support libraries \"23.1.1\".

compile \'com.android.support:appcompat-v7:23.1.1\'
compile \'com.android.support:supp         


        
相关标签:
7条回答
  • 2020-12-24 06:45

    I had a similar problem. It endend up being that the recycler was not the problem. Check that your CardView item measurements translate to something like this:

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ...
    />
    

    If you're not using CardView, ensure that the element you use in your Adapter for the view has android:layout_height="wrap_content" and not match_parent.

    If that fails to work, you can add another attribute setting the minHeight or maxHeight for the view item.

    0 讨论(0)
  • 2020-12-24 06:46

    Update

    It appears that you are updating the LayoutParam for your View in your Adapter.

    It is possible to tell this because your UI appears absolutely fine until you begin scrolling. This means that your XML is correct as it is defined in your XML layout file.

    The fact that it changes after scrolling begins, means there is a logic error in your onBindViewHolder implementation. That is why the error appears when you scroll down, and then the error sticks when you scroll back up.

    Old answer

    Your issue is that your divider has gone rogue:

    <View
        android:layout_width="1px"
        android:layout_height="match_parent"
        android:background="?attr/buyPortfolioSeperatorBackground"
        android:layout_marginRight="5dp"
        android:layout_marginLeft="5dp" />
    

    For testing purposes, set it to:

    <View
        android:layout_width="1px"
        android:layout_height="30dp"
        android:background="?attr/buyPortfolioSeperatorBackground"
        android:layout_marginRight="5dp"
        android:layout_marginLeft="5dp" />
    

    Make sure you change both of them!

    0 讨论(0)
  • 2020-12-24 06:49

    Just make row_layout height to wrap_content so it will take only row actual height space to all the items.

    0 讨论(0)
  • 2020-12-24 07:02

    The height of recycle view must be "wrap_content" only. The recycle view will handle height if the size of cell increases.

    buy_portfolio_fragment.xml

     <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/buyPortfolioListViewBackground"
            android:requiresFadingEdge="none"
            android:scrollbars="vertical"
            android:paddingTop="@dimen/default_tab_layout_height"
            android:clipToPadding="false" />
    
    0 讨论(0)
  • 2020-12-24 07:05

    To fix this bug row_layout should have height fixed or wrap_content! I also had this problem and just realized that the height of row_layout was match_parent.

    0 讨论(0)
  • 2020-12-24 07:09

    I believe this is the problematic line:

    <View   android:layout_width="1px"
                android:layout_height="match_parent"    <!--change this to wrap_content-->
                android:background="?attr/buyPortfolioSeperatorBackground"
                android:layout_marginRight="5dp"
                android:layout_marginLeft="5dp" />
    

    There are 2 places in your layout item that has layout_height="match_parent". You should change them both to wrap_content.

    0 讨论(0)
提交回复
热议问题