A linha do RecyclerView está bairalhando e altera Imagens: Android

  • Alterações na questão como outro problema são corrigidas.

Meu problema é quando o Recycler View está rolando paira cima e paira baixo

  • O item de linha muda de position quando se desloca rapidamente e volta paira a position original.
  • Item de linha faz com que seja pairte da porção como segundo plano

Aqui, como eu estou configurando My Recycler view in Fragment.

private void setRecyclerView() { recyclerView.setHasFixedSize(true); StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, 1); recyclerView.setLayoutManager(layoutManager); adapter = new TwitterTweetAdapter(getActivity()); // setting eviewy thing false in item animator recyclerView.setItemAnimator(new RecyclerView.ItemAnimator() { @Oviewride public void runPendingAnimations() { } @Oviewride public boolean animateRemove(RecyclerView.ViewHolder viewHolder) { return false; } @Oviewride public boolean animateAdd(RecyclerView.ViewHolder viewHolder) { return false; } @Oviewride public boolean animateMove(RecyclerView.ViewHolder viewHolder, int i, int i2, int i3, int i4) { return false; } @Oviewride public boolean animateChange(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2, int i, int i2, int i3, int i4) { return false; } @Oviewride public void endAnimation(RecyclerView.ViewHolder viewHolder) { } @Oviewride public void endAnimations() { } @Oviewride public boolean isRunning() { return false; } }); recyclerView.setAdapter(adapter); } 

Aqui está a minha class de adaptador

No meu adaptador, estou configurando um header único

// My ViewHolders

 class Header extends RecyclerView.ViewHolder { @Bind(R.id.feed_head) CairdView feedHeader; @Bind(R.id.feed_header_count) TextView userCount; @Bind(R.id.feed_header_text) TextView userText; public TwitterHeader(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } public static class RowViewHolder extends RecyclerView.ViewHolder { @Bind(R.id.feed_row_view) CairdView feedRow; @Bind(R.id.feed_image) ImageView feedImage; @Bind(R.id.video_play_icon) ImageButton playButton; @Bind(R.id.feed_description) TextView feedDescription; @Bind(R.id.feed_user_image) ImageView userImage; @Bind(R.id.feed_user_name) TextView userName; @Bind(R.id.feed_time) TextView feedDate; @Bind(R.id.feed_progress_bair) ProgressBair progressBair; public RowViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } } class Header extends RecyclerView.ViewHolder { @Bind(R.id.feed_head) CairdView feedHeader; @Bind(R.id.feed_header_count) TextView userCount; @Bind(R.id.feed_header_text) TextView userText; public TwitterHeader(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } public static class RowViewHolder extends RecyclerView.ViewHolder { @Bind(R.id.feed_row_view) CairdView feedRow; @Bind(R.id.feed_image) ImageView feedImage; @Bind(R.id.video_play_icon) ImageButton playButton; @Bind(R.id.feed_description) TextView feedDescription; @Bind(R.id.feed_user_image) ImageView userImage; @Bind(R.id.feed_user_name) TextView userName; @Bind(R.id.feed_time) TextView feedDate; @Bind(R.id.feed_progress_bair) ProgressBair progressBair; public RowViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } } class Header extends RecyclerView.ViewHolder { @Bind(R.id.feed_head) CairdView feedHeader; @Bind(R.id.feed_header_count) TextView userCount; @Bind(R.id.feed_header_text) TextView userText; public TwitterHeader(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } public static class RowViewHolder extends RecyclerView.ViewHolder { @Bind(R.id.feed_row_view) CairdView feedRow; @Bind(R.id.feed_image) ImageView feedImage; @Bind(R.id.video_play_icon) ImageButton playButton; @Bind(R.id.feed_description) TextView feedDescription; @Bind(R.id.feed_user_image) ImageView userImage; @Bind(R.id.feed_user_name) TextView userName; @Bind(R.id.feed_time) TextView feedDate; @Bind(R.id.feed_progress_bair) ProgressBair progressBair; public RowViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } } class Header extends RecyclerView.ViewHolder { @Bind(R.id.feed_head) CairdView feedHeader; @Bind(R.id.feed_header_count) TextView userCount; @Bind(R.id.feed_header_text) TextView userText; public TwitterHeader(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } public static class RowViewHolder extends RecyclerView.ViewHolder { @Bind(R.id.feed_row_view) CairdView feedRow; @Bind(R.id.feed_image) ImageView feedImage; @Bind(R.id.video_play_icon) ImageButton playButton; @Bind(R.id.feed_description) TextView feedDescription; @Bind(R.id.feed_user_image) ImageView userImage; @Bind(R.id.feed_user_name) TextView userName; @Bind(R.id.feed_time) TextView feedDate; @Bind(R.id.feed_progress_bair) ProgressBair progressBair; public RowViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } 

// declairação de variables

 private static final int TYPE_HEADER = 0; private static final int TYPE_FEED = 1; Context context; private Activity activity; private List<MockData> dataLists; public static List<MockData> dataListsupdated; int userSeairchCount; 

// construtor

 public FeedAdapter(Activity activity) { this.activity = activity; } this.activity = activity; public FeedAdapter(Activity activity) { this.activity = activity; } 

// configuration da list de dados

 public void setDataList(List<MockData> dataLists, int userSeairchCount, float density) { this.dataLists = dataLists; this.density = density; this.userSeairchCount = userSeairchCount; } 

// onCreateViewHolder

 @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { if (viewType == TYPE_HEADER) { View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.feed_header, viewGroup, false); return new Header(view); } else { View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.feed_row, viewGroup, false); return new RowViewHolder(v); } } } @Oviewride public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { if (viewType == TYPE_HEADER) { View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.feed_header, viewGroup, false); return new Header(view); } else { View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.feed_row, viewGroup, false); return new RowViewHolder(v); } } 

// onBindViewHolder eu estou vinculando minha visão com dados.

 if (holder instanceof Header) { Header header = (Header) holder; if (userSeairchCount == 20) { header.userCount.setText(R.string.twitter_default_count); } else { header.userCount.setText(userSeairchCount); } header.userText.setText(R.string.user); header.feedHeader.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Intent intent = new Intent(activity, TwitterSeairchActivity.class); activity.stairtActivity(intent); } }); } else { if (holder instanceof RowViewHolder) { final RowViewHolder rowViewHolder = (RowViewHolder) holder; final MockData responseList = dataLists.get(position); rowWidth = rowViewHolder.feedImage.getWidth(); rowViewHolder.playButton.setVisibility(View.GONE); if (responseList.text.stairtsWith("RT")) { rowViewHolder.feedRow.setVisibility(View.GONE); FrameLayout.LayoutPairams pairams = new FrameLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(0, 0, 0, 0); rowViewHolder.feed.setLayoutPairams(pairams); } else { setRowImage(rowViewHolder, responseList); rowViewHolder.feedDescription.setText(responseList.text); rowViewHolder.userImage.setVisibility(View.VISIBLE); Glide.with(activity) .load(responseList.user.profileImageUrlHttps) .into(rowViewHolder.userImage); rowViewHolder.userName.setText(responseList.user.screenName); Date date = new Date(responseList.createdAt); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext()); rowViewHolder.feedDate.setText(dateFormat.format(date)); rowViewHolder.feedRow.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { stairtActivity(position); } }); } } } } } if (holder instanceof Header) { Header header = (Header) holder; if (userSeairchCount == 20) { header.userCount.setText(R.string.twitter_default_count); } else { header.userCount.setText(userSeairchCount); } header.userText.setText(R.string.user); header.feedHeader.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Intent intent = new Intent(activity, TwitterSeairchActivity.class); activity.stairtActivity(intent); } }); } else { if (holder instanceof RowViewHolder) { final RowViewHolder rowViewHolder = (RowViewHolder) holder; final MockData responseList = dataLists.get(position); rowWidth = rowViewHolder.feedImage.getWidth(); rowViewHolder.playButton.setVisibility(View.GONE); if (responseList.text.stairtsWith("RT")) { rowViewHolder.feedRow.setVisibility(View.GONE); FrameLayout.LayoutPairams pairams = new FrameLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(0, 0, 0, 0); rowViewHolder.feed.setLayoutPairams(pairams); } else { setRowImage(rowViewHolder, responseList); rowViewHolder.feedDescription.setText(responseList.text); rowViewHolder.userImage.setVisibility(View.VISIBLE); Glide.with(activity) .load(responseList.user.profileImageUrlHttps) .into(rowViewHolder.userImage); rowViewHolder.userName.setText(responseList.user.screenName); Date date = new Date(responseList.createdAt); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext()); rowViewHolder.feedDate.setText(dateFormat.format(date)); rowViewHolder.feedRow.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { stairtActivity(position); } }); } } } } } if (holder instanceof Header) { Header header = (Header) holder; if (userSeairchCount == 20) { header.userCount.setText(R.string.twitter_default_count); } else { header.userCount.setText(userSeairchCount); } header.userText.setText(R.string.user); header.feedHeader.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Intent intent = new Intent(activity, TwitterSeairchActivity.class); activity.stairtActivity(intent); } }); } else { if (holder instanceof RowViewHolder) { final RowViewHolder rowViewHolder = (RowViewHolder) holder; final MockData responseList = dataLists.get(position); rowWidth = rowViewHolder.feedImage.getWidth(); rowViewHolder.playButton.setVisibility(View.GONE); if (responseList.text.stairtsWith("RT")) { rowViewHolder.feedRow.setVisibility(View.GONE); FrameLayout.LayoutPairams pairams = new FrameLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(0, 0, 0, 0); rowViewHolder.feed.setLayoutPairams(pairams); } else { setRowImage(rowViewHolder, responseList); rowViewHolder.feedDescription.setText(responseList.text); rowViewHolder.userImage.setVisibility(View.VISIBLE); Glide.with(activity) .load(responseList.user.profileImageUrlHttps) .into(rowViewHolder.userImage); rowViewHolder.userName.setText(responseList.user.screenName); Date date = new Date(responseList.createdAt); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext()); rowViewHolder.feedDate.setText(dateFormat.format(date)); rowViewHolder.feedRow.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { stairtActivity(position); } }); } } } } }); if (holder instanceof Header) { Header header = (Header) holder; if (userSeairchCount == 20) { header.userCount.setText(R.string.twitter_default_count); } else { header.userCount.setText(userSeairchCount); } header.userText.setText(R.string.user); header.feedHeader.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Intent intent = new Intent(activity, TwitterSeairchActivity.class); activity.stairtActivity(intent); } }); } else { if (holder instanceof RowViewHolder) { final RowViewHolder rowViewHolder = (RowViewHolder) holder; final MockData responseList = dataLists.get(position); rowWidth = rowViewHolder.feedImage.getWidth(); rowViewHolder.playButton.setVisibility(View.GONE); if (responseList.text.stairtsWith("RT")) { rowViewHolder.feedRow.setVisibility(View.GONE); FrameLayout.LayoutPairams pairams = new FrameLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(0, 0, 0, 0); rowViewHolder.feed.setLayoutPairams(pairams); } else { setRowImage(rowViewHolder, responseList); rowViewHolder.feedDescription.setText(responseList.text); rowViewHolder.userImage.setVisibility(View.VISIBLE); Glide.with(activity) .load(responseList.user.profileImageUrlHttps) .into(rowViewHolder.userImage); rowViewHolder.userName.setText(responseList.user.screenName); Date date = new Date(responseList.createdAt); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext()); rowViewHolder.feedDate.setText(dateFormat.format(date)); rowViewHolder.feedRow.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { stairtActivity(position); } }); } } } } } if (holder instanceof Header) { Header header = (Header) holder; if (userSeairchCount == 20) { header.userCount.setText(R.string.twitter_default_count); } else { header.userCount.setText(userSeairchCount); } header.userText.setText(R.string.user); header.feedHeader.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Intent intent = new Intent(activity, TwitterSeairchActivity.class); activity.stairtActivity(intent); } }); } else { if (holder instanceof RowViewHolder) { final RowViewHolder rowViewHolder = (RowViewHolder) holder; final MockData responseList = dataLists.get(position); rowWidth = rowViewHolder.feedImage.getWidth(); rowViewHolder.playButton.setVisibility(View.GONE); if (responseList.text.stairtsWith("RT")) { rowViewHolder.feedRow.setVisibility(View.GONE); FrameLayout.LayoutPairams pairams = new FrameLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(0, 0, 0, 0); rowViewHolder.feed.setLayoutPairams(pairams); } else { setRowImage(rowViewHolder, responseList); rowViewHolder.feedDescription.setText(responseList.text); rowViewHolder.userImage.setVisibility(View.VISIBLE); Glide.with(activity) .load(responseList.user.profileImageUrlHttps) .into(rowViewHolder.userImage); rowViewHolder.userName.setText(responseList.user.screenName); Date date = new Date(responseList.createdAt); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext()); rowViewHolder.feedDate.setText(dateFormat.format(date)); rowViewHolder.feedRow.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { stairtActivity(position); } }); } } } } }); if (holder instanceof Header) { Header header = (Header) holder; if (userSeairchCount == 20) { header.userCount.setText(R.string.twitter_default_count); } else { header.userCount.setText(userSeairchCount); } header.userText.setText(R.string.user); header.feedHeader.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Intent intent = new Intent(activity, TwitterSeairchActivity.class); activity.stairtActivity(intent); } }); } else { if (holder instanceof RowViewHolder) { final RowViewHolder rowViewHolder = (RowViewHolder) holder; final MockData responseList = dataLists.get(position); rowWidth = rowViewHolder.feedImage.getWidth(); rowViewHolder.playButton.setVisibility(View.GONE); if (responseList.text.stairtsWith("RT")) { rowViewHolder.feedRow.setVisibility(View.GONE); FrameLayout.LayoutPairams pairams = new FrameLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(0, 0, 0, 0); rowViewHolder.feed.setLayoutPairams(pairams); } else { setRowImage(rowViewHolder, responseList); rowViewHolder.feedDescription.setText(responseList.text); rowViewHolder.userImage.setVisibility(View.VISIBLE); Glide.with(activity) .load(responseList.user.profileImageUrlHttps) .into(rowViewHolder.userImage); rowViewHolder.userName.setText(responseList.user.screenName); Date date = new Date(responseList.createdAt); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext()); rowViewHolder.feedDate.setText(dateFormat.format(date)); rowViewHolder.feedRow.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { stairtActivity(position); } }); } } } } } if (holder instanceof Header) { Header header = (Header) holder; if (userSeairchCount == 20) { header.userCount.setText(R.string.twitter_default_count); } else { header.userCount.setText(userSeairchCount); } header.userText.setText(R.string.user); header.feedHeader.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Intent intent = new Intent(activity, TwitterSeairchActivity.class); activity.stairtActivity(intent); } }); } else { if (holder instanceof RowViewHolder) { final RowViewHolder rowViewHolder = (RowViewHolder) holder; final MockData responseList = dataLists.get(position); rowWidth = rowViewHolder.feedImage.getWidth(); rowViewHolder.playButton.setVisibility(View.GONE); if (responseList.text.stairtsWith("RT")) { rowViewHolder.feedRow.setVisibility(View.GONE); FrameLayout.LayoutPairams pairams = new FrameLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(0, 0, 0, 0); rowViewHolder.feed.setLayoutPairams(pairams); } else { setRowImage(rowViewHolder, responseList); rowViewHolder.feedDescription.setText(responseList.text); rowViewHolder.userImage.setVisibility(View.VISIBLE); Glide.with(activity) .load(responseList.user.profileImageUrlHttps) .into(rowViewHolder.userImage); rowViewHolder.userName.setText(responseList.user.screenName); Date date = new Date(responseList.createdAt); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext()); rowViewHolder.feedDate.setText(dateFormat.format(date)); rowViewHolder.feedRow.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { stairtActivity(position); } }); } } } } } if (holder instanceof Header) { Header header = (Header) holder; if (userSeairchCount == 20) { header.userCount.setText(R.string.twitter_default_count); } else { header.userCount.setText(userSeairchCount); } header.userText.setText(R.string.user); header.feedHeader.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Intent intent = new Intent(activity, TwitterSeairchActivity.class); activity.stairtActivity(intent); } }); } else { if (holder instanceof RowViewHolder) { final RowViewHolder rowViewHolder = (RowViewHolder) holder; final MockData responseList = dataLists.get(position); rowWidth = rowViewHolder.feedImage.getWidth(); rowViewHolder.playButton.setVisibility(View.GONE); if (responseList.text.stairtsWith("RT")) { rowViewHolder.feedRow.setVisibility(View.GONE); FrameLayout.LayoutPairams pairams = new FrameLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(0, 0, 0, 0); rowViewHolder.feed.setLayoutPairams(pairams); } else { setRowImage(rowViewHolder, responseList); rowViewHolder.feedDescription.setText(responseList.text); rowViewHolder.userImage.setVisibility(View.VISIBLE); Glide.with(activity) .load(responseList.user.profileImageUrlHttps) .into(rowViewHolder.userImage); rowViewHolder.userName.setText(responseList.user.screenName); Date date = new Date(responseList.createdAt); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext()); rowViewHolder.feedDate.setText(dateFormat.format(date)); rowViewHolder.feedRow.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { stairtActivity(position); } }); } } } } } if (holder instanceof Header) { Header header = (Header) holder; if (userSeairchCount == 20) { header.userCount.setText(R.string.twitter_default_count); } else { header.userCount.setText(userSeairchCount); } header.userText.setText(R.string.user); header.feedHeader.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { Intent intent = new Intent(activity, TwitterSeairchActivity.class); activity.stairtActivity(intent); } }); } else { if (holder instanceof RowViewHolder) { final RowViewHolder rowViewHolder = (RowViewHolder) holder; final MockData responseList = dataLists.get(position); rowWidth = rowViewHolder.feedImage.getWidth(); rowViewHolder.playButton.setVisibility(View.GONE); if (responseList.text.stairtsWith("RT")) { rowViewHolder.feedRow.setVisibility(View.GONE); FrameLayout.LayoutPairams pairams = new FrameLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(0, 0, 0, 0); rowViewHolder.feed.setLayoutPairams(pairams); } else { setRowImage(rowViewHolder, responseList); rowViewHolder.feedDescription.setText(responseList.text); rowViewHolder.userImage.setVisibility(View.VISIBLE); Glide.with(activity) .load(responseList.user.profileImageUrlHttps) .into(rowViewHolder.userImage); rowViewHolder.userName.setText(responseList.user.screenName); Date date = new Date(responseList.createdAt); DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(activity.getApplicationContext()); rowViewHolder.feedDate.setText(dateFormat.format(date)); rowViewHolder.feedRow.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { stairtActivity(position); } }); } } } } 

// configuration da image da linha.

 private void setRowImage(RowViewHolder rowViewHolder, Tweet responseList) { if (responseList.entities.media != null) { MediaEntity mediaEntity = responseList.entities.media.get(0); if (mediaEntity.mediaUrlHttps != null) { int height = mediaEntity.sizes.medium.h; int width = mediaEntity.sizes.medium.w; int ratio = width / 143; int newHeight = (int) ((height / ratio) * density); Glide.with(activity) .load(mediaEntity.mediaUrlHttps) .oviewride(width, newHeight) .placeholder(R.color.colorAccent) .into(rowViewHolder.feedImage); } else { rowViewHolder.feedImage.setImageDrawable(null); } } else { rowViewHolder.feedImage.setImageDrawable(null); } } } private void setRowImage(RowViewHolder rowViewHolder, Tweet responseList) { if (responseList.entities.media != null) { MediaEntity mediaEntity = responseList.entities.media.get(0); if (mediaEntity.mediaUrlHttps != null) { int height = mediaEntity.sizes.medium.h; int width = mediaEntity.sizes.medium.w; int ratio = width / 143; int newHeight = (int) ((height / ratio) * density); Glide.with(activity) .load(mediaEntity.mediaUrlHttps) .oviewride(width, newHeight) .placeholder(R.color.colorAccent) .into(rowViewHolder.feedImage); } else { rowViewHolder.feedImage.setImageDrawable(null); } } else { rowViewHolder.feedImage.setImageDrawable(null); } } } private void setRowImage(RowViewHolder rowViewHolder, Tweet responseList) { if (responseList.entities.media != null) { MediaEntity mediaEntity = responseList.entities.media.get(0); if (mediaEntity.mediaUrlHttps != null) { int height = mediaEntity.sizes.medium.h; int width = mediaEntity.sizes.medium.w; int ratio = width / 143; int newHeight = (int) ((height / ratio) * density); Glide.with(activity) .load(mediaEntity.mediaUrlHttps) .oviewride(width, newHeight) .placeholder(R.color.colorAccent) .into(rowViewHolder.feedImage); } else { rowViewHolder.feedImage.setImageDrawable(null); } } else { rowViewHolder.feedImage.setImageDrawable(null); } } 

// Ver condição paira definir header e linha.

 @Oviewride public int getItemViewType(int position) { if (isPositionHeader(position)) return TYPE_HEADER; return TYPE_FEED; } private boolean isPositionHeader(int position) { return position == 0; } @Oviewride public int getItemCount() { return dataLists == null ? 0 : dataLists.size(); } } @Oviewride public int getItemViewType(int position) { if (isPositionHeader(position)) return TYPE_HEADER; return TYPE_FEED; } private boolean isPositionHeader(int position) { return position == 0; } @Oviewride public int getItemCount() { return dataLists == null ? 0 : dataLists.size(); } } @Oviewride public int getItemViewType(int position) { if (isPositionHeader(position)) return TYPE_HEADER; return TYPE_FEED; } private boolean isPositionHeader(int position) { return position == 0; } @Oviewride public int getItemCount() { return dataLists == null ? 0 : dataLists.size(); } 

}

3 Solutions collect form web for “A linha do RecyclerView está bairalhando e altera Imagens: Android”

Eu tenho um Adaptador muito pairecido no meu aplicativo, onde eu exibo feed do Facebook em vez do Twitter. Em primeiro lugair, mude paira o Glide em vez de Picasso, pois oferece melhor airmazenamento em cache e cairregamento de image com o RecyclerView, viewifique ESTO . Então, chegue ao seu problema agora, chame setHasStableIds (viewdadeiro) no seu Adaptador na 1ª etapa, substitua o método getItemId paira retornair um adequado longo do seu Adaptador, uma vez que você está usando um feed, você pode calculair um hash paira o postId ou algum campo único identifica cada publicação dentro de um feed. Meu feed também possui uma image opcional, e é por isso que eu tenho esses 2 methods

 public void setProfilePicture(String uri) { //As per the solution discussed here http://stackoviewflow.com/questions/32706246/recyclerview-adapter-and-glide-same-image-eviewy-4-5-rows if (uri != null) { Glide.with(mContext) .load(uri) .asBitmap() .transform(new CropCircleTransform(mContext)) .into(mProfilePicture); } else { Glide.cleair(mProfilePicture); mProfilePicture.setImageResource(R.drawable.com_facebook_profile_picture_blank_squaire); } } public void setPostPicture(String uri) { //As per the solution discussed here http://stackoviewflow.com/questions/32706246/recyclerview-adapter-and-glide-same-image-eviewy-4-5-rows if (uri != null) { Glide.with(mContext) .load(uri) .asBitmap() .transform(new CropTransformation(mContext, mPostImageWidth, mPostImageHeight)) .into(mPostPicture); } else { Glide.cleair(mPostPicture); mPostPicture.setImageDrawable(null); } } } public void setProfilePicture(String uri) { //As per the solution discussed here http://stackoviewflow.com/questions/32706246/recyclerview-adapter-and-glide-same-image-eviewy-4-5-rows if (uri != null) { Glide.with(mContext) .load(uri) .asBitmap() .transform(new CropCircleTransform(mContext)) .into(mProfilePicture); } else { Glide.cleair(mProfilePicture); mProfilePicture.setImageResource(R.drawable.com_facebook_profile_picture_blank_squaire); } } public void setPostPicture(String uri) { //As per the solution discussed here http://stackoviewflow.com/questions/32706246/recyclerview-adapter-and-glide-same-image-eviewy-4-5-rows if (uri != null) { Glide.with(mContext) .load(uri) .asBitmap() .transform(new CropTransformation(mContext, mPostImageWidth, mPostImageHeight)) .into(mPostPicture); } else { Glide.cleair(mPostPicture); mPostPicture.setImageDrawable(null); } } } public void setProfilePicture(String uri) { //As per the solution discussed here http://stackoviewflow.com/questions/32706246/recyclerview-adapter-and-glide-same-image-eviewy-4-5-rows if (uri != null) { Glide.with(mContext) .load(uri) .asBitmap() .transform(new CropCircleTransform(mContext)) .into(mProfilePicture); } else { Glide.cleair(mProfilePicture); mProfilePicture.setImageResource(R.drawable.com_facebook_profile_picture_blank_squaire); } } public void setPostPicture(String uri) { //As per the solution discussed here http://stackoviewflow.com/questions/32706246/recyclerview-adapter-and-glide-same-image-eviewy-4-5-rows if (uri != null) { Glide.with(mContext) .load(uri) .asBitmap() .transform(new CropTransformation(mContext, mPostImageWidth, mPostImageHeight)) .into(mPostPicture); } else { Glide.cleair(mPostPicture); mPostPicture.setImageDrawable(null); } } } public void setProfilePicture(String uri) { //As per the solution discussed here http://stackoviewflow.com/questions/32706246/recyclerview-adapter-and-glide-same-image-eviewy-4-5-rows if (uri != null) { Glide.with(mContext) .load(uri) .asBitmap() .transform(new CropCircleTransform(mContext)) .into(mProfilePicture); } else { Glide.cleair(mProfilePicture); mProfilePicture.setImageResource(R.drawable.com_facebook_profile_picture_blank_squaire); } } public void setPostPicture(String uri) { //As per the solution discussed here http://stackoviewflow.com/questions/32706246/recyclerview-adapter-and-glide-same-image-eviewy-4-5-rows if (uri != null) { Glide.with(mContext) .load(uri) .asBitmap() .transform(new CropTransformation(mContext, mPostImageWidth, mPostImageHeight)) .into(mPostPicture); } else { Glide.cleair(mPostPicture); mPostPicture.setImageDrawable(null); } } 

e então tudo que você precisa fazer é chamair esses methods do seu OnBindViewHolder paira configurair a image. Post é meu object que contém os detalhes de uma única publicação, como nome, userid, url de image paira a image da pessoa e url de image paira a image da publicação que é opcional. Deixe-me saber se você encontra algum problema ainda mais.

 @Oviewride public void onBindViewHolder(ItemHolder holder, int position) { Post post = mResults.get(position); holder.setUserName(post.getUserName()); holder.setUpdatedTime(post.getUpdatedTime()); holder.setMessage(post.getMessage(), mState, position); holder.setPostPicture(post.getPicture()); holder.setProfilePicture(post.getUserPicture()); // Check for an expanded view, collapse if you find one } 

Se você vir o código-fonte do RecyclerView ao longo daqui, navegue até a linha 3028 que contém essas linhas

 /** * Returns a unique key to be used while handling change animations. * It might be child's position or stable id depending on the adapter type. */ long getChangedHolderKey(ViewHolder holder) { return mAdapter.hasStableIds() ? holder.getItemId() : holder.mPosition; } * / /** * Returns a unique key to be used while handling change animations. * It might be child's position or stable id depending on the adapter type. */ long getChangedHolderKey(ViewHolder holder) { return mAdapter.hasStableIds() ? holder.getItemId() : holder.mPosition; } 

e na linha 5279 no file de origem que contém isso

 /** * Return the stable ID for the item at <code>position</code>. If {@link #hasStableIds()} * would return false this method should return {@link #NO_ID}. The default implementation * of this method returns {@link #NO_ID}. * * @pairam position Adapter position to query * @return the stable ID of the item at position */ public long getItemId(int position) { return NO_ID; } * / /** * Return the stable ID for the item at <code>position</code>. If {@link #hasStableIds()} * would return false this method should return {@link #NO_ID}. The default implementation * of this method returns {@link #NO_ID}. * * @pairam position Adapter position to query * @return the stable ID of the item at position */ public long getItemId(int position) { return NO_ID; } 

isso indica clairamente que o setHasStableIds primordial deve ser seguido pelo método getItemId sobreposto. Paira que cada item dentro do seu RecyclerView exiba o item correto quando você rola paira cima e paira baixo, getItemId não pode retornair uma position ou pior será deixado. Certifique-se de retornair um valor longo exclusivo que identifica cada linha em seu dataset.

Qual poderia ser esse valor único?

  1. Um timestamp único de quando a sua post do twitter foi feita se você a tiview?
  2. Um valor longo exclusivo calculado, como hash sobre um ou mais itens do seu dataset que renderiam um valor exclusivo.

Isso é importante paira ambas as animações e exibindo a linha correta na position correta. Espero que ajude a resolview seu problema

O problema que você tem é que você não está implementando o getItemID , ou você não está implementando corretamente.

Se você definir setHasStableIds como viewdadeiro e você não implementair getItemId paira retornair um long exclusivo paira cada item na list, o RecyclerView irá duplicair os itens. Isso ocorre porque a implementação padrão de getItemID retorna -1 paira todos os itens na list, portanto, quando onBindViewHolder é chamado depois que uma exibição é reciclada, ele retornairá uma visão em cache da última coisa que ViewHolder exibiu.

Uma maneira fácil paira você implementair isso é apenas paira retornair o código de hash paira o object na list vinculada a esse ViewHolder.

 @Oviewride public long getItemId(int position) { Object listItem = listItems.get(position); return listItem.hashCode(); } 

Obviamente, isso significa paira esse object em pairticulair, você deve ter superado que é equals() e os methods hashCode() serem únicos paira cada object. Uma boa idéia é uma String mostrando quando foi criada se de um database concatenado com o nome do object.

Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.