基本上我想要像this (at the 30 second mark)
这样的东西我希望我的项目在活动开始后按顺序滑动。
我试过谷歌搜索。我找不到任何我能理解的东西。我仍然在开发这个为Android开发应用程序的疯狂世界。
感谢。
答案 0 :(得分:15)
在recyclerView上添加动画,如下所示
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);
答案 1 :(得分:4)
您需要在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();
}
}
此处更多信息http://frogermcs.github.io/Instagram-with-Material-Design-concept-is-getting-real/(查看FeedAdapter)