Android develops an example of gradient navigation bar effect based on Scrollview

This paper describes the effect of gradient navigation bar developed by Android based on Scrollview. Share with you for your reference, as follows:

A few days ago, the project wanted to add the function of gradient navigation bar to the original page. I checked a lot of data. Many resources monitor the height of listview to achieve the effect of gradient navigation bar, but many interfaces in the project use Scrollview to achieve sliding effect.

There was no way, so I wrote a test to achieve this effect.

In fact, the gradient navigation bar is nothing more than changing the transparency of the navigation bar, that is, you can set a height and monitor the Scrollview sliding distance according to this height, so as to achieve the effect of the gradient navigation bar.

Let's look at the code

First, customize a Scrollview

1、ObservableScrollView.java

There are two interfaces defined

2、ObservableScrollable.java

3、OnScrollChangedCallback.java

The callback function here implements the monitoring of Scrollview

Then there is the main method

4、MainActivity.java

Set the monitoring of Scrollview in main, set the monitoring height to 500, and divide 500 into 100% to change the gradient navigation bar

Then inherit the observablescrollview class from the XML file.

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.

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