Android sliding component suspended and fixed on the top effect
The effects to be achieved are as follows:
Scene: sometimes it is a component in the middle of the content, which is fixed on the top when sliding to the top.
Implementation ideas:
1. There are two sets of target buttons, which are placed at the top and in the middle of the content;
2. When the component in the middle of the content slides to the top bar position, control to display / hide the components at the top and in the middle (involving the component to obtain the position knowledge points on the screen);
Activity Code:
Key points analysis:
1. Obtain the height of the screen status bar and title bar in the onwindowfocuschanged() method (0 in the oncreate() method);
2. Because the onscrollchangelister() method of the Scrollview in the layout does not support ― > in the lower version API, the activity implements the onscrollchanged() interface method in the custom Scrollview ― > in this method, the display / hiding of components is realized;
Code for customizing Scrollview:
Then the layout file:
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.