<分区>
The way I am doing it is: I am having a
ListView
. With the animation fade-out for the first Visible Child inside the ListView. But this does not seems to be working.
请就如何实现这一目标给我建议。谢谢!
<分区>
The way I am doing it is: I am having a
ListView
. With the animation fade-out for the first Visible Child inside the ListView. But this does not seems to be working.
请就如何实现这一目标给我建议。谢谢!
最佳答案
这是对一个已有 2 年历史的问题的回答,但将来可能会对其他人有所帮助。
您可以使用 Recycler View 来完成此操作结合Count Down Timer和 Alpha Animation
事情是这样的
在 Adapter 中的 onBindViewHolder 方法中,创建一个绑定(bind)到每个创建的消息/ TextView 的 CountDownTimer 实例。这样每条发布的消息都附有一个计时器。
new CountDownTimer(5000, 1000){ //(timer_duration, timer_interval) @Override public void onTick(long millisUntilFinished) { //runs every second (1000 ms) } @Override public void onFinish() { //Do your operations when timer is finised setFadeAnimation(viewHolder.comment_layout_container); userCommentList.remove(userComment);
viewHolder.comment_layout_container.setVisibility(View.INVISIBLE); } }.start();
当计时器针对发布的特定消息/文本结束时,然后在 onFinish() 中您可以调用一个函数来淡出 View 。为 FADE_DURATION 声明一个适合您需要的全局变量或局部变量。
int FADE_DURATION = 1000; // in milliseconds
private void setFadeAnimation(LinearLayout view) {
/*sets animation from complete opaque state(1.0f) to complete transparent state(0.0f)*/
AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f);
anim.setDuration(FADE_DURATION);
view.startAnimation(anim);
注意 - 这是我设法做到的方式,我才 3-4 个月进入 Android 开发。这更接近于潜望镜风格的评论部分布局。显然,总有改进的余地。 Atlas 我要感谢 SO 社区。p>
关于android - 潜望镜评论动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34824573/
相关文章:
android - Gmail 三段动画场景的完整工作示例?
android - 有没有一种方法可以将 BackgroundColorSpan 设置为 SpannableString?
android - fragment 生命周期 : when "ondestroy" and "ondestroyview" are not called?
android - ListView 项目的删除选项总是删除第一个项目,无论单击哪个项目
android - Gradle 5 中 Artifact 的分类?
android - 根据另一个 RV 滚动增加和减少 RV 高度