RecyclerView CardView Bug
See original GitHub issueI’m using the Kotlin Builder (ViewBinding) way to init the recyclerView, When trying to bind my layout with a cardView, it won’t respect the match_parent width, its always wrap content The strange thing is, it worked with a normal RecyclerView, pretty sure it’s a problem from the lib, please take a look
here is the layout of the single Item
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:cardView="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="90dp"
cardView:cardPreventCornerOverlap="true"
cardView:cardCornerRadius="8dp"
cardView:cardElevation="8dp"
android:layout_margin="8dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image_restaurant"
android:layout_width="130dp"
android:layout_height="0dp"
android:scaleType="centerInside"
cardView:layout_constraintBottom_toBottomOf="parent"
cardView:layout_constraintStart_toStartOf="parent"
cardView:layout_constraintTop_toTopOf="parent"
tools:background="@tools:sample/backgrounds/scenic"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/restaurant_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:fontFamily="sans-serif-smallcaps"
android:gravity="center"
android:lines="1"
android:padding="5dp"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textColor="@android:color/black"
android:textStyle="bold"
cardView:layout_constraintStart_toEndOf="@id/image_restaurant"
cardView:layout_constraintEnd_toEndOf="parent"
cardView:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/full_names" />
<TextView
android:id="@+id/openingHours"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Dimanche - jeudi 21h30 jeudi 21h30 jeudi 21h30 jeudi 21h30 jeudi 21h30 22-40"
android:textStyle="bold"
cardView:layout_constraintBottom_toBottomOf="parent"
cardView:layout_constraintEnd_toEndOf="parent"
cardView:layout_constraintStart_toEndOf="@+id/image_restaurant"
cardView:layout_constraintTop_toBottomOf="@+id/restaurant_name" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
CardView is not showing properly in RecyclerView
I have compiled card view library in gradle file but the problem is card view is not showing there is no elevation and...
Read more >Android avoid weird cardview and recyclerview bugs caused ...
Android avoid weird cardview and recyclerview bugs caused by different support library dependencies. - build.gradle.
Read more >v7 cardview library issues [37007602] - Visible to Public
https://github.com/bignerdranch/recyclerview-multiselect. This error occurs every time on 4.4.4, but not on 5.0 and occurs at times on 4.1.2 ...
Read more >CardView using RecyclerView in Android with Example
RecyclerView works on the ViewHolder design pattern so we have to create a Data class that holds data for RecyclerView and a ViewHolder...
Read more >Android RecyclerView, Android CardView Example Tutorial
Android CardView widget allows us to control the background color, shadow, corner radius, elevation etc. For using the custom attributes in XML, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/amirisback/frogo-recycler-view/blob/master/app/src/main/java/com/frogobox/apprecycler/sample/issue/AnswerIssueActivity.kt
This is my code… glad to help
I’ve tried it, everything works fine, you can try my sample code