Android development and implementation of the method of sliding and changing color with Scrollview
This paper describes the method of changing color with Scrollview sliding in Android development. Share with you for your reference, as follows:
In order to realize that the background transparency of a view changes with the Scrollview sliding, the onoverscrolled method of Scrollview needs to be re used. This method responds to the sliding changes (including finger sliding and finger moving inertia sliding), so it is most suitable for color change processing.
Step1: set layout
Because we want to change the background transparency of the title when sliding, and the title view at the fixed top cannot follow the sliding in srcollview, we need to layout as follows:
Step 2: add the required method
When sliding, a view needs to change color. After re Scrollview, add a method to let it know that the view needs to change color
The color change during sliding needs to refer to the sliding height of a sub view in the Scrollview. If the screen is completely drawn on the sub view, the background transparency of the title view is 0:
Add another setting. If you don't want the background transparency gradient:
Step3: code implementation
The effects are as follows:
Before sliding
Sliding discoloration
After the referenced view exceeds the screen
More readers interested in Android related content can view the topics on this site: summary of Android basic component usage, introduction and advanced tutorial of Android development, summary of Android layout skills, summary of Android view skills, summary of activity operation skills of Android programming, summary of Android resource operation skills, and Android control usage summary
I hope this article will help you in Android programming.