Android imitation Taobao view slides to the top of the screen and will always stay at the top

In the just completed project, in one page, the user experience engineer proposed that the check-in button leading the user to operate should always be kept in the page. No matter how long the page can scroll, it must stay in the visual area of the page. The final effect is shown in the figure below:

As shown in the figure, the view in the red box will always stay on the page. If you slide to the top of the page, it will always remain on the top.

The specific implementation ideas are as follows:

Idea: in fact, there are two views with the same visual effect in the whole page. This effect is achieved by hiding and displaying the view through the sliding position. The process of sliding the whole page up and down can be summarized into two states: state a (as shown in Figure 1). When view2 is in the visual area, view1 is not visible. In state B (as shown in Figure 2), view2 slides over the visual area. In this state, view1 is visible and view2 is not visible.

Timing of view display and hiding: 1. When the page slides upward, at the moment when it changes from state a to state B, view1 just slides to the moment when the top coincides with view2 to display view1;

2. When the page slides down and changes from state B to state a, view2 just coincides with view1 and hides view1.

Viewallshowlinearlayout class

Use effect in the project:

The above is the Android imitation Taobao view introduced by Xiaobian. Sliding to the top of the screen will always stay at the top. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

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
分享
二维码
< <上一篇
下一篇>>