簡體   English   中英

折疊工具欄標題消失

[英]Collapsing Toolbar Title Disappear

我在設計支持庫23.0.1上,我正在使用帶有視差圖像的折疊工具欄布局。 我不明白為什么當工具欄完全折疊(固定)時,如果單擊一個操作按鈕(特別是我刷新其圖像), 標題就會消失 之后,如果我將標題下拉到總擴展並重新點擊操作按鈕,標題將返回。

活動布局

<!-- App bar -->
<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="150dp"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <!-- Collapsing toolbar layout -->
    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginBottom="32dp"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <!-- Image Parallax -->
        <ImageView
            android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:contentDescription=""
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            edo:layout_collapseMode="parallax" />

        <!-- Toolbar -->
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            edo:popupTheme="@style/ThemeOverlay.AppCompat.Light">

        </android.support.v7.widget.Toolbar>

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

<!-- Nested scroll view -->
<android.support.v4.widget.NestedScrollView
    android:id="@+id/nested_scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    edo:layout_behavior="@string/appbar_scrolling_view_behavior">

</android.support.v4.widget.NestedScrollView>

動作菜單布局

<item
    android:id="@+id/action_bookmark"
    android:icon="@mipmap/bookmark_empty_white"
    android:title="@string/add_news_to_bookmarks"
    app:showAsAction="ifRoom" />

選擇的選項

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (news != null) {
        switch (item.getItemId()) {
            case R.id.action_bookmark:
                if (Utils.isNetworkAvailable(activity)) {
                    if (news.getBookmarked()) {
                        bookmarked = false;
                        item.setIcon(R.mipmap.bookmark_empty_white);
                        deleteBookmark();
                    } else {
                        bookmarked = true;
                        item.setIcon(R.mipmap.bookmark_white);
                        postBookmark();
                    }
                } else {
                    handleError(Config.API_ERR_CONNECTION);
                }

                return true;
        }
    }

    return super.onOptionsItemSelected(item);
}

這是Android方面的一個錯誤。 他們了解它並且可能會在將來的版本中修復: https//code.google.com/p/android/issues/detail?id = 183333

變通方法發布在鏈接中,但沒有一個能夠解決我的問題。

編輯:問題已通過支持庫v23.1.0修復

這個錯誤似乎是通過支持庫v23.1.0修復的

我有這個奇怪的問題

並從android:fitsSystemWindows="true"刪除屬性android:fitsSystemWindows="true"對我AppBarLayout 你能嘗試一下嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM