Jef*_*pez 5 android android-recyclerview
基本上我想要这样的东西(在30秒标记处)
一旦活动开始,我希望我的项目顺序滑动.
我试过谷歌搜索.我找不到任何我能理解的东西.我仍然在开发这个为Android开发应用程序的疯狂世界.
谢谢.
Mus*_*bal 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);
Run Code Online (Sandbox Code Playgroud)
您需要在 RecyclerView 的 AdapteronBindViewHolder方法中运行动画。
@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();
}
}
Run Code Online (Sandbox Code Playgroud)
更多信息在这里http://frogermcs.github.io/Instagram-with-Material-Design-concept-is-getting-real/(看看FeedAdapter)
| 归档时间: |
|
| 查看次数: |
7545 次 |
| 最近记录: |