您好,欢迎光临本网站![请登录][注册会员]  
文件名称: Andoid瀑布流效果
  所属分类: Android
  开发工具:
  文件大小: 6mb
  下载次数: 0
  上传时间: 2015-11-08
  提 供 者: qq_23******
 详细说明: /** 单元中要显示的图片Bitmap */ private Bitmap imageBmp; /** 图像文件的路径 */ private String imageFilePath; /** 单元的宽度,也是图像的宽度 */ private int width; /** 单元的高度,也是图像的高度 */ private int height; /** 画笔 */ private Paint paint; /** 图像绘制区域 */ private Rect rect; /** 这个单元的底部到它所在列的顶部之间的距离 */ private int footHeight; public FlowingView(Context context, int index, int width) { super(context); this.index = index; this.width = width; init(); } /** * 基本初始化工作 */ private void init() { setOnClickListener(this); setOnLongCli ckListener(this); paint = new Paint(); paint.setAntiAlias(true); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension(width, height); } @Override protected void onDraw(Canvas canvas) { //绘制图像 canvas.drawColor(Color.WHITE); if (imageBmp != null && rect != null) { canvas.drawBitmap(imageBmp, null, rect, paint); } super.onDraw(canvas); } /** * 被WaterFall调用异步加载图片数据 */ public void loadImage() { InputStream inStream = null; try { inStream = getContext().getAssets().open(imageFilePath); imageBmp = BitmapFactory.decodeStream(inStream); inStream.close(); inStream = null; } catch (IOException e) { e.printStackTrace(); } if (imageBmp != null) { int bmpWidth = imageBmp.getWidth(); int bmpHeight = imageBmp.getHeight(); height = (int) (bmpHeight * width / bmpWidth); rect = new Rect(0, 0, width, height); } } /** * 重新加载回收了的Bitmap */ public void reload() { if (imageBmp == null) { new Thread(new Runnable() { @Override public void run() { InputStream inStream = null; try { inStream = getContext().getAssets().open(imageFilePath); imageBmp = BitmapFactory.decodeStream(inStream); inStream.close(); inStream = null; postInvalidate(); } catch (IOException e) { e.printStackTrace(); } } }).start(); } } /** * 防止OOM进行回收 */ public void recycle() { if (imageBmp == null || imageBmp.isRecycled()) return; new Thread(new Runnable() { @Override public void run() { imageBmp.recycle(); imageBmp = null; postInvalidate(); } }).start(); } @Override public boolean onLongClick(View v) { Toast.makeText(getContext(), "long click : " + index, Toast.LENGTH_SHORT).show(); return true; } @Override public void onClick(View v) { Toast.makeText(getContext(), "click : " + index, Toast.LENGTH_SHORT).show(); } /** * 获取单元的高度 * @return */ public int getViewHeight() { return height; } /** * 设置图片路径 * @param imageFilePath */ public void setImageFilePath(String imageFilePath) { this.imageFilePath = imageFilePath; } public Bitmap getImageBmp() { return imageBmp; } public void setImageBmp(Bitmap imageBmp) { this.imageBmp = imageBmp; } public int getFootHeight() { return footHeight; } public void setFootHeight(int footHeight) { this.footHeight = footHeight; } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: Android
 输入关键字,在本站1000多万海量源码库中尽情搜索: