android - How to make glide display like picasso? -
i've been using picasso's library load images gridview in application , works , looks i'd like. users telling me images loading slowly. know because of poor network speed , picasso loading full images big , resizing them fit image view. tried using glide loads images in twice speed on images it's not keeping structure picasso does. example picasso loading images looks
whilst glide loading them has different states here's loads initially
and after scrolling looks
and after lots of scrolling looks
i pretty confident due images sizes being different , seems making placeholder image different size has effect want know how glide keep initial state, or how picasso load quicker? i've heard lowering color format 888 565 has dramatic effect, can lend me there 2 cents? , suggestions
edit
this imageview
<imageview android:layout_width="match_parent" android:layout_height="wrap_content" android:scaletype="fitxy" android:id="@+id/imageview"/>
this how calling picasso
picasso.with(getactivity()) .load(mthumbids[position]) .placeholder(r.drawable.placeholder) .fit() .into(imageview); return imageview;
and how calling glide
glide.with(getactivity()) .load(mthumbids[position]) .asbitmap() .placeholder(r.drawable.placeholder) .diskcachestrategy(diskcachestrategy.all) .fitcenter() .error(r.drawable.ic_photos) .into(imageview); return imageview;
and if matters gridview
<gridview android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="5dp" android:id="@+id/gridview" android:numcolumns="2" android:gravity="center" android:drawselectorontop="true" android:listselector="@drawable/ripple" android:stretchmode="columnwidth" >
by default, glide attempt keep aspect ratio of images. when use fitcenter()
, implies want whole image visible , centered within available area. switching centercrop()
first step in making sure image fills both height , width available it.
however, running longstanding issue gridview
: assumes columns have same height. yet, use wrap_content
imageview
's height, causing each element resized differently based on incoming height (remember, glide's perspective, said imageview
can tall needs be!).
if have dominant aspect ratio (say, 16:9), use fixed aspect ratio view such this aspectratioimageview use same height based on width of column (set gridview
). another, more complicated, option switch recyclerview , use staggeredgridlayoutmanager, allow keep aspect ratio of each image , stagger rows, ensuring each image fills space , keeps aspect ratio.
Comments
Post a Comment