How do I (insert) an entry element in a RecyclerView?

Basically, I want something like this (with a 30 second mark)

I want my objects to slide sequentially after the start of the action.

I tried google. I did not find anything that I could understand. I'm still wading through this crazy world of Android app development.

Thanks.

+5
source share
2 answers

Add animation to recyclerView like this

recyclerView = (RecyclerView) findViewById(R.id.rv); recyclerView.setHasFixedSize(true); llm = new LinearLayoutManager(getApplicationContext()); recyclerView.setLayoutManager(llm); AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500); set.addAnimation(animation); animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f ); animation.setDuration(100); set.addAnimation(animation); controller = new LayoutAnimationController(set, 0.5f); adapter = new RecycleViewAdapter(poetNameSetGets, this); recyclerView.setLayoutAnimation(controller); 
+13
source

You need to run the animation inside the RecyclerView Adapter onBindViewHolder .

 @Override public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { runEnterAnimation(viewHolder.itemView); } private void runEnterAnimation(View view) { view.setTranslationY(Utils.getScreenHeight(context)); view.animate() .translationY(0) .setInterpolator(new DecelerateInterpolator(3.f)) .setDuration(700) .start(); } } 

More details here http://frogermcs.imtqy.com/Instagram-with-Material-Design-concept-is-getting-real/ (look at FeedAdapter)

+3
source

Source: https://habr.com/ru/post/1233860/


All Articles