Detailed Implementation of android waterfall stream, with source code Introduction
Reference: Workshop
Original Author:
I tried to slide smoothly on 10 thousand sheets without memory overflow.
Design Concept
650) this. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "title =" Waterfall "border =" 0 "alt =" Waterfall "src =" http://img1.51cto.com/attachment/201209/21/3357586_1348212035rm9I.png "width =" 341 "height =" 484 "/>
Previously, the custom view of the author only slides one layer on the master, and other settings must be set on the corresponding activity. In my opinion, it is difficult to reuse, so I decided to encapsulate one layer. now it takes only five steps to define a default waterfall stream. The following shows the source code. For details, see the source code...
// 1 initialize waterfall
Waterfall_scroll = (WaterFallView) findViewById (R. id. waterfall_scroll );
// 2 initialize the display container
Waterfall_container = (LinearLayout) findViewById (R. id. waterfall_container );
// 3. Set the rolling listener
Waterfall_scroll.setOnScrollListener (this );
// 4. An instance setting
WaterFallOption fallOption = new WaterFallOption (waterfall_container, width of each column, number of columns );
// 5. Submit the changes to implement the android waterfall stream
Waterfall_scroll.commitWaterFall (fallOption, waterfall_scroll );
Finally, do not forget to scroll the listener to the bottom.
@ Override public void onBottom () {AddItemToContainer (++ (waterfall_scroll.current_page), waterfall_scroll.pageCount );}
Known bugs
The bug here also exists...
- Scrolling too fast, leading to the inability to display some images
Enhanced Functions
- Supports URL-based image loading.