Open EloneMusk opened 9 years ago
Try this.. only AlphaInAnimationAdapter working in this case. I too facing this issue.
mAdapter = new CardView(titles);
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(mAdapter);
alphaAdapter.setDuration(1000);
mRecyclerView.setAdapter(alphaAdapter);
What you have set?
CardView with images, some text. Do you want me to paste Adapter code?
Yes. please show me the code.
public class CardView extends RecyclerView.Adapter<CardView.ViewHolder> {
public String[] titles, descriptions, images;
OnItemClickListener mItemClickListener;
ImageLoader mImageLoader;
public CardView(String[] titles, String[] descriptions, String[] images) {
this.titles = titles;
this.descriptions = descriptions;
this.images = images;
}
@Override
public CardView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view, parent, false);
mImageLoader = VolleySingleton.getInstance().getImageLoader();
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(CardView.ViewHolder holder, int position) {
holder.cardViewTitle.setText(titles[position]);
holder.cardViewText.setText(descriptions[position]);
holder.cardNetworkImageView.setImageUrl(images[position], mImageLoader);
}
@Override
public int getItemCount() {
return titles.length;
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
NetworkImageView cardNetworkImageView;
TextView cardViewTitle, cardViewText;
public ViewHolder(View itemView) {
super(itemView);
cardNetworkImageView = (NetworkImageView) itemView.findViewById(R.id.cardViewImage);
cardViewTitle = (TextView) itemView.findViewById(R.id.cardViewTitle);
cardViewText = (TextView) itemView.findViewById(R.id.cardViewText);
itemView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (mItemClickListener != null) {
mItemClickListener.onItemClick(v, getPosition());
}
}
}
public interface OnItemClickListener {
public void onItemClick(View view, int position);
}
public void SetOnItemClickListener(OnItemClickListener mItemClickListener) {
this.mItemClickListener = mItemClickListener;
}
}
@abhi98228 and @faizsiddiqui ,Let me understand your question. I think you can see the animation while scrolling, but you also want to see the animation when the activity is started? Right?(No?, please make me clear) but If so, let me try to help. If your list data is already loaded. (I means when you do not need to make http call to receive list data). In that case ,Animation would be fast enough so that you might not notice them. Please try inside your onViewCreate() or equivalent method (where you assign view object from XML file's rootView.)
mRecyclerView=(RecyclerView)rootView.findViewById(R.id.myRecyclerView);
recyclerView.post(new Runnable() {
@Override
public void run() {
mAdapter = new CardView(titles);
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(mAdapter);
mRecyclerView.setAdapter(alphaAdapter);
}
});
If still its fast, try by adding timer delay. Check What does post(runnable) do?
@hbb20 No, I'm not even seeing animation on Scrolling. Only "AlphaInAnimationAdapter" working.
Yeah same here. only AlphaInAnimationAdapter work. And others work in 1.1.0 version.
How do I animate the list when my activity starts and list populates