ImageView同寬不同長


Posted by Limon on 2023-06-02

有一個新需求是recyclerView item要每個ImageView寬match_parent,長則依照每個照片不失真為前提,每個照片的長度不一樣。

recyclerView可以設定setHasFixedSize,設定為false recyclerView會依照每個item height wrap_content。

ImageView xml加上

android:adjustViewBounds="true"
android:scaleType="fitStart"

本來我一直在載入圖片的code調整,結果發現在ImageView加上自動調整的屬性就好了

Picasso.get().load(url).placeholder(defaultDrawable).into(imageView);









Related Posts

自學經驗分享

自學經驗分享

一起探討 Micro Frontends 的世界

一起探討 Micro Frontends 的世界

DAY34:Human readable duration format

DAY34:Human readable duration format


Comments