超炫 PullDownListView高仿微信下拉眼睛出现动画

PullDownListView高仿微信下拉眼睛出现动画,动画自定义PullDownListView, pullDownListView.setOnPullHeightChangeListener设置下拉高度监听,onTopHeightChange() onBottomHeightChange(),onRefreshing()其中提供者三个方法时刻刷新页面特效

运行效果:

完整源码下载地址:http://www.itlanbao.com/code/20150911/10000/100524.html

package com.pulldownlistview;

import com.pulldownlistview.PullDownListView.OnPullHeightChangeListener;

import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.TextView;

public class MainActivity extends Activity {  final String TAG = "MainActivity";  static String[] adapterData = new String[] { "A", "B", "C", "D", "E", "F",   "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",   "S", "T", "U", "V", "W", "X", "Y", "Z" };  Context mContext;  @Override  protected void onCreate(Bundle savedInstanceState) {   // TODO Auto-generated method stub   super.onCreate(savedInstanceState);   setContentView(R.layout.activity_main);   mContext = this;   final PullDownListView pullDownListView = (PullDownListView) this     .findViewById(R.id.pullDownListView);   final YProgressView progressView = (YProgressView) this     .findViewById(R.id.progressView);   final EyeView eyeView = (EyeView) this.findViewById(R.id.eyeView);

pullDownListView.getListView().setAdapter(mAdapter);      pullDownListView.setOnPullHeightChangeListener(new OnPullHeightChangeListener(){

@Override    public void onTopHeightChange(int headerHeight,      int pullHeight) {     // TODO Auto-generated method stub     float progress = (float) pullHeight       / (float) headerHeight;          if(progress<0.5){      progress = 0.0f;     }else{      progress = (progress-0.5f)/0.5f;     }               if (progress > 1.0f) {      progress = 1.0f;     }

if (!pullDownListView.isRefreshing()) {      eyeView.setProgress(progress);     }    }

@Override    public void onBottomHeightChange(int footerHeight,      int pullHeight) {     // TODO Auto-generated method stub     float progress = (float) pullHeight       / (float) footerHeight;           if(progress<0.5){      progress = 0.0f;     }else{      progress = (progress-0.5f)/0.5f;     }          if (progress > 1.0f) {      progress = 1.0f;     }          if (!pullDownListView.isRefreshing()) {      progressView.setProgress(progress);     }

}

@Override    public void onRefreshing(final boolean isTop) {     // TODO Auto-generated method stub     if (isTop) {      eyeView.startAnimate();     } else {      progressView.startAnimate();     }

new Handler().postDelayed(new Runnable() {

@Override      public void run() {       // TODO Auto-generated method stub       pullDownListView.pullUp();       if (isTop) {        eyeView.stopAnimate();       } else {        progressView.stopAnimate();       }      }

}, 3000);    }       });

pullDownListView.getListView().setOnItemClickListener(     new OnItemClickListener() {

@Override      public void onItemClick(AdapterView<?> arg0, View arg1,        int arg2, long arg3) {       // TODO Auto-generated method stub

}

});

}    private BaseAdapter mAdapter = new BaseAdapter(){

@Override   public int getCount() {    // TODO Auto-generated method stub    return adapterData.length;   }

@Override   public Object getItem(int position) {    // TODO Auto-generated method stub    return adapterData[position];   }

@Override   public long getItemId(int position) {    // TODO Auto-generated method stub    return 0;   }      @Override   public View getView(int position, View convertView, ViewGroup parent) {    // TODO Auto-generated method stub    TextView textView = new TextView(mContext);    textView.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,dp2px(mContext,50)));    textView.setText(adapterData[position]);    textView.setTextSize(20);    textView.setTextColor(0xff000000);    textView.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);    textView.setPadding(50, 0, 0, 0);        return textView;   }     };    public static int dp2px(Context context, int dp) {   return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,     context.getResources().getDisplayMetrics());  } }

时间: 2024-11-10 06:30:29

超炫 PullDownListView高仿微信下拉眼睛出现动画的相关文章

PullDownListView高仿微信下拉眼睛出现动画

PullDownListView高仿微信下拉眼睛出现动画,动画自定义PullDownListView,pullDownListView.setOnPullHeightChangeListener设置下拉高度监听,onTopHeightChange()onBottomHeightChange(),onRefreshing()其中提供者三个方法时刻刷新页面特效 查看项目完整源码:http://www.itlanbao.com/code/20150911/10000/100524.html 引入布局:

MeiTuanRefreshListView高仿美团下拉刷新《IT蓝豹》

MeiTuanRefreshListView高仿美团下拉刷新 MeiTuanRefreshListView高仿美团下拉刷新,本项目来自:https://github.com/nugongshou110/MeiTuanRefreshListView项目主要构成部分:自定义MeiTuanRefreshFirstStepView,MeiTuanRefreshSecondStepView,MeiTuanRefreshThirdStepView,其中自定义MeiTuanListView继承了ListVie

Android开发仿微信下拉关闭图片11

图片会跟随手指移动,只有是下滑时才会退出查看页面,其他情况会复位,直接当做ImageView使用即可,setViewCall方法是在下滑完成后要执行的操作,上,左,右,可自行扩展 onTouchEvent 监听手指坐标,GestureDetector 监听滑动的惯性,ViewHelper设置图片位移动画 public class FriendCircleView extends android.support.v7.widget.AppCompatImageView implements Ges

0126——动画(类似微信下拉眼睛)

效果图 首先你得画出这只眼睛,这是眼睛包括5个部分组成: 1 @property (strong, nonatomic) CAShapeLayer *eyeFirstLightLayer; 2 @property (strong, nonatomic) CAShapeLayer *eyeSecondLightLayer; 3 @property (strong, nonatomic) CAShapeLayer *eyeballLayer; 4 @property (strong, nonatom

类似微信下拉眼睛UI

public class EyeView extends FrameLayout { private Paint paint; private Bitmap bitmap; public EyeView(Context context) { super(context); init(); } public EyeView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public EyeView(C

Android 修改源码自定义SwipeRefreshLayout样式——高仿微信朋友圈下拉刷新

修改源码自定义SwipeRefreshLayout样式——高仿微信朋友圈下拉刷新 原文地址:https://www.cnblogs.com/zhujiabin/p/8194996.html

ASP.NET仿新浪微博下拉加载更多数据瀑布流效果

闲来无事,琢磨着写点东西.貌似页面下拉加载数据,瀑布流的效果很火,各个网站都能见到各式各样的展示效果,原理大同小异.于是乎,决定自己写一写这个效果,希望能给比我还菜的菜鸟们一点参考价值. 在开始之前,先把实现的基本原理说一下.当夜幕下拉到底部的时候,js可以判断滚动条的位置,到达底部触发js方法,执行jquery的ajax方法,向后台一般处理程序夜幕ashx文件请求数据源,得到json格式的数据源.然后,遍历json数据源,拼接一个li标签,再填充到页面上去. 首先,我们来做个简单的html页面

Android 高仿微信实时聊天 基于百度云推送

转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/38799363 ,本文出自:[张鸿洋的博客] 一直在仿微信界面,今天终于有幸利用百度云推送仿一仿微信聊天了~~~ 首先特别感谢:weidi1989分享的Android之基于百度云推送IM ,大家可以直接下载:省了很多事哈,本例中也使用了weidi的部分代码,凡是@author way的就是weidi1989的代码~~ 1.效果图 核心功能也就上面的两张图了~~~我拿着手机和模拟器

安卓开发复习笔记——Fragment+ViewPager组件(高仿微信界面)

什么是ViewPager? 关于ViewPager的介绍和使用,在之前我写过一篇相关的文章<安卓开发复习笔记——ViewPager组件(仿微信引导界面)>,不清楚的朋友可以看看,这里就不再重复. 什么是Fragment? Fragment是Android3.0后新增的概念,Fragment名为碎片,不过却和Activity十分相似,具有自己的生命周期,它是用来描述一些行为或一部分用户界面在一个Activity中,我们可以合并多个Fragment在一个单独的activity中建立多个UI面板,或