Two ways to realize waterfall flow in Android

Source: Internet
Author: User

How about the waterfall, I don't introduce more. Here are the two ways I think about it.
Method One, the overlay of the control:
Scrollview+linearlayout. Add a horizontal linearlayout in the ScrollView, add several vertical linearlayout in the horizontal layout, and then load and recycle the bitmap according to the sliding condition. can even recycle ImageView (recovery bitmap at the same time remove the ImageView, load bitmap while addview, need to grasp the location of the view), the idea is better realized.

Method Two, custom ViewGroup:
Load the picture, remember the picture information (width, height, url, etc.), and calculate the position of the picture should be placed, in ViewGroup add ImageView used to display the picture, then realize ViewGroup OnLayout method, In the OnLayout method, the Imageview.layout () method is called based on the computed picture position information. Picture arrangement, need to handle the slide, in the Ontouch event to use Scrollby/scrollto to achieve the effect of sliding, at the same time can be action_up inside to deal with the effect of sliding rebound fling. It is important to note that ViewGroup does not intercept the touch event by default. Here, you need to override the Onintercepttouchevent method so that it returns true to intercept the touch event.

Two ways to realize waterfall flow in Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.