It Working in fine in old project which is written in java
When same things written in kotlin its not working...
Problem RecyclerView Item Height Too Large
lateinit var mImageProcessedRecyclerViewAdapater:ImageProcessedRecyclerViewAdapater
lateinit var mImageContainerAfterProcess: RecyclerView
//initializing adapter and itemdecoration
mImageContainerAfterProcess= findViewById(R.id.ImageContainerAfterProcess)
mImageContainerAfterProcess.addItemDecoration(RecyclerViewItemDecoration(16))
mImageContainerAfterProcess.layoutManager=StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
mImageContainerAfterProcess.adapter=mImageProcessedRecyclerViewAdapater
item view xml file
<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="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/processedImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Activity Layout File which contains recyclerview
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activitis.ImageProcess">
// layout height and width is match_constraint
<android.support.v7.widget.RecyclerView
android:id="@+id/ImageContainerAfterProcess"
android:layout_width="0dp"
android:layout_height="0dp"
tools:listitem="@layout/processd_image_item_view"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</android.support.constraint.ConstraintLayout>
i cant find out what i am doing wrong
output capture via layout inspector
My Old Project output
wrap_content
does not behave in a similar way with constraint layout. To achieve what you want you will need to add below code to yourImageView
and set its width and height to0dp