ViewAnimator实现按钮切换动画
来源:互联网 发布:淘宝上的黑科技产品 编辑:程序博客网 时间:2024/05/16 07:51
<?xml version="1.0" encoding="utf-8"?><translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="100" android:fromYDelta="80%p" android:interpolator="@android:anim/linear_interpolator" android:toYDelta="0" /><?xml version="1.0" encoding="utf-8"?><translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="100" android:fromYDelta="0" android:interpolator="@android:anim/linear_interpolator" android:toYDelta="-80%p" /><?xml version="1.0" encoding="utf-8"?><merge xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/tvSend" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="SEND" android:textColor="#ffffff" android:textSize="12sp" /> <TextView android:id="@+id/tvDone" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="✓" android:textColor="#ffffff" android:textSize="12sp" /></merge>
public class SendCommentButton extends ViewAnimator implements View.OnClickListener { public static final int STATE_SEND = 0; public static final int STATE_DONE = 1; private static final long RESET_STATE_DELAY_MILLIS = 2000; private int currentState; private OnSendClickListener onSendClickListener; private Runnable revertStateRunnable = new Runnable() { @Override public void run() { setCurrentState(STATE_SEND); } }; public SendCommentButton(Context context) { super(context); init(); } public SendCommentButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } private void init() { LayoutInflater.from(getContext()).inflate(R.layout.view_send_comment_button, this, true); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); currentState = STATE_SEND; super.setOnClickListener(this); } @Override protected void onDetachedFromWindow() { removeCallbacks(revertStateRunnable); super.onDetachedFromWindow(); } public void setCurrentState(int state) { if (state == currentState) { return; } currentState = state; if (state == STATE_DONE) { setEnabled(false); postDelayed(revertStateRunnable, RESET_STATE_DELAY_MILLIS); setInAnimation(getContext(), R.anim.slide_in_done); setOutAnimation(getContext(), R.anim.slide_out_send); } else if (state == STATE_SEND) { setEnabled(true); setInAnimation(getContext(), R.anim.slide_in_send); setOutAnimation(getContext(), R.anim.slide_out_done); } showNext(); } @Override public void onClick(View v) { if (onSendClickListener != null) { onSendClickListener.onSendClickListener(this); } } public void setOnSendClickListener(OnSendClickListener onSendClickListener) { this.onSendClickListener = onSendClickListener; } @Override public void setOnClickListener(OnClickListener l) { //Do nothing, you have you own onClickListener implementation (OnSendClickListener) } public interface OnSendClickListener { public void onSendClickListener(View v); }}
0 0
- ViewAnimator实现按钮切换动画
- android视图切换动画:ViewAnimator类及其子类
- Android自定义View--使用ViewAnimator实现一个提交按钮
- ViewAnimator-view切换组件
- Android学习笔记(25):带动画效果的View切换ViewAnimator及其子类
- ViewFlipper 视图切换组件 ViewAnimator
- VC++实现切换按钮
- duilib动画按钮实现
- duilib动画按钮实现
- 动画按钮实现
- ViewPager 切换动画实现
- ObjectAnimator 属性动画 缩放, ViewAnimator的用法
- 切换CSS实现开/关按钮切换
- ActionBar按钮动画的实现
- android按钮动画的实现
- 点击按钮实现缩放动画
- android 学习 实现切换动画,
- ViewPager实现的切换动画
- ScrollView嵌套GridView
- 《超实用的Node.js代码段》连载二:正确拼接Buffer
- Servlet生命周期与工作原理
- AutoCompleteTextView可以直接与sqlite数据库绑定 模糊查询
- Invalidate()mfc函数使用,摘录自csdn以为网友回答。
- ViewAnimator实现按钮切换动画
- 我的代码日程
- Redis 学习 ---- 3.链表 Linked List
- 用ImageLoader加载圆角图片(不是圆形)
- 显著性水平 置信度 置信区间 实例讲解
- tomcat session实现原理
- linked list cycle
- C++第2次实验(提高班)—类和对象1
- 杭电acm 题目分类