toolbar not appearing in pre lollipop devices

房东的猫 提交于 2019-12-04 10:24:58

This is a common issue becoming less apparent when testing on Lollipop or later.

When using standard layouts (such as FrameLayout, RelativeLayout etc.) the default behavior is that child views get drawn in order they are added or inflated.

The fix would look similar to this:

<FrameLayout>
     <!-- Content will be drawn first - below the toolbar. -->
     <FrameLayout android:id="@+id/main_content" />
     <!-- Toolbar will be drawn next - above the content. -->
     <android.support.v7.widget.Toolbar android:id="@+id/toolbar" />
</FrameLayout>

However since Lollipop the android:elevation attribute can override this behavior. Since elevation defines precise position along the Z axis views with higher elevation values will be drawn above those with lower elevation values.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!