Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在牛轧糖上运行时,为什么在使用折叠工具栏布局时标题会被截断?_Android_Android Collapsingtoolbarlayout - Fatal编程技术网

Android 在牛轧糖上运行时,为什么在使用折叠工具栏布局时标题会被截断?

Android 在牛轧糖上运行时,为什么在使用折叠工具栏布局时标题会被截断?,android,android-collapsingtoolbarlayout,Android,Android Collapsingtoolbarlayout,我正在使用下面的布局,它在所有版本上都非常有效,除了Android Nougat,它的标题在完全折叠时被切掉 我已经尝试了app:collapsedTitleGravity=“center”,但没有解决问题。我怎样才能让牛轧糖起作用呢?问题是 还有比删除fitsSystemWindows更好的选择, 只需添加到onCreatecollasingToolbarLayout.post{collasingToolbarLayout.requestLayout()}删除android:fitsSy

我正在使用下面的布局,它在所有版本上都非常有效,除了Android Nougat,它的标题在完全折叠时被切掉


我已经尝试了app:collapsedTitleGravity=“center”,但没有解决问题。我怎样才能让牛轧糖起作用呢?

问题是

还有比删除
fitsSystemWindows
更好的选择,
只需添加到
onCreate
collasingToolbarLayout.post{collasingToolbarLayout.requestLayout()}
删除android:fitsSystemWindows=“true”
解决了我的问题

这显示了如何在Android中实现折叠工具栏。

在runnable中发布
requestLayout
对我不起作用,但如果您使用
AppCompatActivity
,您可以将
设置支持ActionBar
与工具栏一起使用,它似乎可以工作

是否有人面临同样的问题?这是一个完美的片段,但不在活动中。有人知道只有在活动中才会发生这种情况吗?感谢您提到这一点,特别是修复,但请注意,如果没有
可运行的
,您的帖子块将无法工作。
<android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/them_color"
            app:expandedTitleTextAppearance="@android:color/transparent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/header_image"
                android:layout_width="match_parent"
                android:layout_height="300dp"
                android:contentDescription="@string/app_name"
                android:fitsSystemWindows="true"
                android:scaleType="fitXY"
                app:layout_collapseMode="parallax"/>

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

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