如何解决状态栏透明之后,toolbar与状态栏的重叠问题

当我们想要将状态栏变为透明,可在styles.xml文件中进行设置:

true
效果:二者重合,且toolbar悬浮在状态栏之后

解决方法:

设置fitsystemWindow属性,该属性的官方文档说明,如下

fitsystemwindow属性,官方文档如下:

Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.

Must be a boolean value, either “true” or “false”.

该属性设置为true时,表示view会根据系统栏自动设置Padding值来适配,即为屏幕自动加入padding,使得所有内容都可以显示在主屏上,从而避免toolbar被状态栏覆盖。







你可能感兴趣的:(★Android,UI)