Implementation of long press mask effect for Taobao product list of Android

Let's take a look at the effects of Taobao and vipshop by product, as well as the effects of a simple demo:

First, analyze the scenario:

When long pressing an item, the effect of pop-up mask is obscured on the original item layout; Slide the page or click another item, and the mask of the last item being masked disappears. When long pressing other items, the item of the previous mask cancels the mask, and the current long pressing display mask; Add animation when items are masked;

1. The effect of mask, we can easily think of the Android layout control FrameLayout layout, which is based on the layout superimposed on the top. Therefore, the FrameLayout layout can be used in the layout of list items. When long clicking list items, add a mask layout with the root layout of items to achieve the desired effect.

@H_ 404_ 29@

2. Record the root layout of the current long press. If you click or long press other list items, or slide the page (add activity monitoring), the mask of the previously long press items will be cancelled, and it is OK to delete the mask layout from the root layout of the items;

3. View animation or attribute animation can be used to display animation when adding mask layout;

Next, let's talk about the code:

1. First, define the mask layout and customize the view as required

2. Encapsulate a help class, which mainly points to the layout of list items according to the long pressed items according to the member variables of the class, and then adds the effect of masking for the items;

3. When sliding the recyclerview list, listen for sliding, remove the mask, directly define the subclass of recyclerview, and add sliding listening callback;

The above is the main code implementation part. By flexibly extending the application of itemlongclickmaskhelper, we can basically achieve a long press mask effect similar to that of Taobao. I hope it will help you in your study, and I also hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>