首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓工具栏上带图片的CollapsingToolbarLayout

安卓工具栏上带图片的CollapsingToolbarLayout
EN

Stack Overflow用户
提问于 2016-12-17 18:06:19
回答 1查看 6.9K关注 0票数 1

我正在使用CollapsingToolbarLayout,我想在工具栏上显示个人资料图片以及标题,当collapsingToolbarLayout提升up.Please提供相关代码或库时。

EN

回答 1

Stack Overflow用户

发布于 2016-12-17 18:41:47

像这样使用:

代码语言:javascript
复制
 <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:fitsSystemWindows="false"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleTextAppearance="@style/TransparentText"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">


            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clickable="true"
                android:foreground="?attr/selectableItemBackground"
                android:orientation="vertical"

                android:paddingTop="?actionBarSize"
                app:layout_collapseMode="parallax">


                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/test_img"
                    android:id="@+id/profile_image">

                </ImageView>


            </FrameLayout>


            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </android.support.design.widget.CollapsingToolbarLayout>


    </android.support.design.widget.AppBarLayout>

在你的coordinateLayout中使用它。然后根据你的喜好来定位你的图像。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41197448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档