Skip to content

Commit

Permalink
Merge pull request #35 from Trendyol/slidable_content_scale_problems
Browse files Browse the repository at this point in the history
fix slidable content scale & height problems
  • Loading branch information
sumrukarss authored Jun 13, 2024
2 parents 66a4cf8 + c2eddf4 commit cd51eea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.trendyol.showcase.databinding.ItemSlidableContentBinding
import com.trendyol.showcase.ui.loadImage
import com.trendyol.showcase.ui.setTextSizeInSp
import com.trendyol.showcase.util.getHeightInPixels

internal class SlidableContentAdapter(private val slidableContentList: List<SlidableContent>) :
RecyclerView.Adapter<SlidableContentAdapter.ViewPagerViewHolder>() {
Expand Down Expand Up @@ -57,9 +58,14 @@ internal class SlidableContentAdapter(private val slidableContentList: List<Slid
isVisible = viewState.isDescriptionVisible()
setTextSizeInSp(viewState.slidableContent.descriptionTextSize)
}

imageView.layoutParams.height =
binding.root.context.resources.getHeightInPixels() / SLIDABLE_IMAGE_HEIGHT_RATIO
imageView.loadImage(viewState.slidableContent.imageUrl)
}
}
}

companion object {
private const val SLIDABLE_IMAGE_HEIGHT_RATIO = 5
}
}
5 changes: 3 additions & 2 deletions library/src/main/res/layout/item_slidable_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="140dp"
android:scaleType="centerCrop"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down

0 comments on commit cd51eea

Please sign in to comment.