Android listview slide change title bar background gradient effect

First slide up the listview to change the gradient effect of the title bar background, and the transparency will change to the opacity effect:

Figure 1:

Figure 2:

Figure 3:

Figure 4:

I use Xiaomi note mobile phone, and the height of the status bar is 55px. As will be mentioned later, here is a description:

The following contains all the code and some test data:

code:

The code is very simple and annotated. There is no nonsense here.

Layout file first:

Layout of activity

activity_ main_ ten

Listview header layout

head_ layout

Item layout of listview

listview_ item_ layout

Function code: mainactivity10

Color:

Add in colors.xml

Tool class code:

Print log tool:

Color tool:

Test data:

The interface has just started

05-18 16:19:25.386 18718-18718/com.chen E/chen: ==location==0==0 05-18 16:19:25.387 18718-18718/com.chen E/chen: ==location==1==0 05-18 16:19:25.387 18718-18718/com.chen E/chen: ==height==0 05-18 16:19:25.387 18718-18718/com.chen E/chen: ==headViewHeight==0 05-18 16:19:25.387 18718-18718/com.chen E/chen: ==setHeigth==413

In terms of time, about 150 milliseconds (0.15 seconds) after startup

05-18 16:19:25.531 18718-18718/com.chen E/chen: ==location==0==0 05-18 16:19:25.531 18718-18718/com.chen E/chen: ==location==1==55 05-18 16:19:25.531 18718-18718/com.chen E/chen: ==height==55 05-18 16:19:25.531 18718-18718/com.chen E/chen: ==headViewHeight==413 05-18 16:19:25.531 18718-18718/com.chen E/chen: ==setHeigth==413

Millet note, the height of the status bar is 55 pixels. So, at the beginning, the height of the picture from the top of the screen is 55

Slide upward. When the head layout is completely out of the screen, continue to slide, and the print data will not change. That is, the height (distance) from the top of the head layout to the top of the screen remains unchanged. Because this height can only be obtained in the view on the screen.

See note for details

05-18 17:01:02.151 16873-16873/com.chen E/chen: ==height==-412 05-18 17:01:02.167 16873-16873/com.chen E/chen: ==height==-412 05-18 17:01:02.200 16873-16873/com.chen E/chen: ==height==-412 05-18 17:01:02.233 16873-16873/com.chen E/chen: ==height==-412 05-18 17:01:02.316 16873-16873/com.chen E/chen: ==height==-412 05-18 17:01:02.332 16873-16873/com .chen E/chen: ==height==-412 05-18 17:01:02.349 16873-16873/com.chen E/chen: ==height==-412

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.

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