[英]Back button not shown on collapsed state in CollapsingToolbarLayout
I have a CollapsingToolbarLayout
It displays the back button on the expanded state, but not showing on the collapsed state. 我有一个
CollapsingToolbarLayout
它在展开状态下显示后退按钮,但在折叠状态下不显示。
I tried setNavigationIcon()
on the Toolbar
but it sets for the expanded state. 我在
Toolbar
上尝试了setNavigationIcon()
,但它设置了扩展状态。
Here is the layout 这是布局
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/user_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorAccent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/tbt_logo"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/user_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:titleTextColor="@android:color/white"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/pen_point_item_layout" />
<include layout="@layout/pen_point_item_layout" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Java: Java的:
toolbar = (Toolbar) findViewById(R.id.user_toolbar);
toolbar.setNavigationIcon(R.drawable.ic_back);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.user_collapsing_toolbar);
collapsingToolbar.setTitle("Profile");
collapsingToolbar.setCollapsedTitleTextColor(Color.WHITE);
collapsingToolbar.setExpandedTitleColor(Color.WHITE);
What should I do? 我该怎么办?
将layout_collapseMode添加到工具栏。
app:layout_collapseMode="pin"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.