简体   繁体   中英

Is it possible to have different layout elements inside CollapsingToolbarLayout?

我正在尝试在CollapsingToolbarLayout内放置包含imageview按钮和其他UI元素的LinearLayout ,这可能吗?

CollapsingToolbarLayout is a subclass of FrameLayout so it has the same behavior and in theory you can have LinearLayout as a child.

But usually CollapsingToolbarLayout should be a direct child of AppBarLayout and it should contain Toolbar . If you need an ImageView as a background you will have something like this:

<android.support.design.widget.AppBarLayout
... >
<android.support.design.widget.CollapsingToolbarLayout
    ... >
    <ImageView
        .../>
    <android.support.v7.widget.Toolbar
        ... />
</android.support.design.widget.CollapsingToolbarLayout>

If you need navigation buttons consider using app:navigationIcon="@drawable/arrow_left" inside Toolbar .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM