android 瀑布流图片实现
来源:互联网 发布:专业心理学书籍知乎 编辑:程序博客网 时间:2024/05/19 05:01
http://blog.csdn.net/xyz_lmn/article/details/8102078
自pinterest使用了瀑布流展示图片后,有很多应用开始使用瀑布流的方式,像蘑菇街,美丽说。这里的瀑布流实现使用了开源代码。
layout:
- <?xml version="1.0" encoding="utf-8"?>
- <com.dodowaterfall.LazyScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:id="@+id/waterfall_scroll"
- android:scrollbars="vertical"
- >
- <LinearLayout
- android:id="@+id/waterfall_container"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@android:color/white"
- >
- </LinearLayout>
- </com.dodowaterfall.LazyScrollView>
整个瀑布流用的是ScrollView的子类LazyScrollView。这个LazyScrollView中设置了一个监听器接口,用来监听ScrollView执行的不同阶段。接口如下:
- public interface OnScrollListener {
- void onBottom();
- void onTop();
- void onScroll();
- void onAutoScroll(int l, int t, int oldl, int oldt);
- }
对于每一幅图,都用一个ImageView的子类FlowView来表示。为了不阻塞UI线程,图片加载和图片更新都分别用不同的线程来做。这两个线程都在FlowView中。FlowView提供了加载和更新的接口给Activity调用。瀑布流实例的主Activity是MainActivity,常量都保存在Constants类中,方便维护。
瀑布流最重要的是图片的内存回收机制,防止发生内存溢出的情况(OOM)。
参考:
https://github.com/dodola/android_waterfall
http://developer.android.com/training/displaying-bitmaps/process-bitmap.html
- android 瀑布流图片实现
- Android使用LruCache、DiskLruCache实现图片缓存+图片瀑布流
- 实现瀑布流排布图片
- 图片瀑布流的实现
- RecyclerView实现图片瀑布流
- Android中RecyclerView实现瀑布流图片显示
- Android ViewPager+RecyclerView+StaggerLayoutManager瀑布流图片单选实现
- Android RecyclerView+StaggeredGridLayoutManager实现瀑布流图片闪烁问题
- android 图片瀑布流效果
- android 瀑布流实现效果
- 【Android-RecyclerView】瀑布流实现
- 【Android-RecyclerView】瀑布流实现
- android 瀑布流 的实现
- Android瀑布流的实现
- Android瀑布流实现二
- Android RecyclerView实现瀑布流
- Volley ImageLoader实现图片瀑布流
- Ajax实现瀑布流图片加载
- Asp.Net自定义错误页心得介绍
- 如何在Windows Azure VM上的SQL Server和Windows Azure SQL Database两者中做出选择
- hdu 1698 Just a Hook(线段树 成段更新)
- servlet的生命周期是什么?jsp都有哪些对象和动作?
- python os.path
- android 瀑布流图片实现
- SQLServer2008导出整个数据库的脚本(并且是带数据的)
- Ubuntu下创建root账户
- JS input文本框禁用右键和复制粘贴功能的代码
- 详解Linux内存使用信息
- Hadoop实战-初级部分-第二部分 Hadoop介绍
- 策略路由
- BeeFramework
- Unity3D学习系列教程