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

Show Me the DAG - An Introduction to Causal Graphs

Show Me the DAG - An Introduction to Causal Graphs

OOP 15 - Interface Segregation Principles

OOP 15 - Interface Segregation Principles

我要成為前端工程師的學習筆記:HTML & CSS 篇 - div、margin、padding Day6

我要成為前端工程師的學習筆記:HTML & CSS 篇 - div、margin、padding Day6


Comments