Android UI开发第二十二篇

自pinterest使用了瀑布流展示图片后,有很多应用开始使用瀑布流的方式,,像蘑菇街,美丽说。这里的瀑布流实现使用了开源代码。

layout:

<?xml version="1.0" encoding="utf-8"?><com.dodowaterfall.LazyScrollView xmlns: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);}

瀑布流最重要的是图片的内存回收机制,防止发生内存溢出的情况(OOM)。

参考:

https://github.com/dodola/android_waterfall

/*** @author 张兴业* 邮箱:xy-zhang#163.com* android开发进阶群:278401545**/

挫折其实就是迈向成功所应缴的学费。

Android UI开发第二十二篇

相关文章:

你感兴趣的文章:

标签云: