Floating Toolbar with Appcompat

前端 未结 6 1213
半阙折子戏
半阙折子戏 2020-12-14 05:27

How to create a floating toolbar like the following image as proposed in the material design guidelines and in the Google Map application.

6条回答
  •  醉话见心
    2020-12-14 05:39

    I've worked with the Toolbar before and all the comments from CommonsWare are absolutely correct.

    The Toolbar widget (https://developer.android.com/reference/android/support/v7/widget/Toolbar.html) have absolutely nothing special or different than any other Viewgroup and does not behave differently than any other ViewGroup.

    Put it inside a FrameLayout, put a layout_margin parameter on it, make the layout_width NOT match_parent and that's it.

    Put it inside an LinearLayout with orientation=horizontal and you can use the layout_weight to control the size in percentage. Or just use plain dip if that suits your needs.

提交回复
热议问题