listview - Dynamic ImageView in list item android -


i developing twitter based app , showing tweets item in recycler view. have imageview in item layout, shown if tweet have image associated it. i'm doing setting imageview visibility gone in xml , if image url present, set imageview visibility visible in onbindview.

i want imageview height dynamic, set height wrap content. when list shown, looks images appear out of , on scrolling othe issues appear when scrolling speed fast imageview showing other image replaced correct image after time , change quite noticeable. so, right i'm using fixed height on imageview scale down image, in short not filling imageview. problem this, if image height less specified height in xml, lot of whitespace above , below imageview appears .i want image appearing in list item big possible without issues mentioned. how can that.

also, i'm using glide load images.

as requested here code:

item_layout

<linearlayout         xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical"         android:padding="5dp">          <textview             android:id="@+id/text_tweet"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:textsize="18sp"             android:linksclickable="true"             android:autolink="web"             android:textcolorlink="@color/primary"/>          <imageview             android:id="@+id/image_tweet"             android:layout_width="match_parent"             android:layout_height="300dp"             android:visibility="gone"             tools:ignore="contentdescription" />  </linearlayout> 

myadapter

@override public void onbindviewholder(final viewholder holder, int position) {     tweet tweet = tweets.get(position);     holder.tweettextview.settext(tweet.descripion);     if (!textutils.isempty(tweet.tweetimage)) {         holder.tweetimageview.setvisibility(view.visible);         glide.with(mcontext)                 .load(tweet.imagurl)                 .crossfade()                 .centercrop()                 .into(holder.tweetimageview);     } } 

centercrop() remove spaces above , below. without fixed height imageview, convertview return previous layout height different new size needed , therefore cause "jumping effects" (layout changes) when scrolling after image loaded if wrap_content used


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -