当前位置: 首页 > 知识库问答 >
问题:

折叠recyclerview上状态栏下的工具栏图像向下滚动

景令秋
2023-03-14

当布局形成时,一切都很好,就像图像是由状态栏形成的,状态栏的颜色是透明的。但是每当我向上滚动然后向下滚动回收器视图时,图像就会滚动到状态栏下。但当我点击图像时,它就会占据原来的位置。

样式代码/V21

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowContentTransitions">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" >
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
</style>

折叠工具栏布局的代码。

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.ashish.swipemusic.GenreDetails">



<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/app_bar_height"
    android:fitsSystemWindows="true"
    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:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed">

        <ImageView
            android:id="@+id/headerArtist"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            android:scaleType="fitXY"
            android:src="@drawable/album_details1"
            />

        <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"
            app:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed"/>

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

<include layout="@layout/content_genre_details" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/fab_margin"
    android:src="@drawable/ic_play_arrow_black_24dp"
    app:layout_anchor="@id/app_bar"
    app:layout_anchorGravity="bottom|end" />
<android.support.v7.widget.RecyclerView
    android:id="@+id/genre_songs_recyclerview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    >

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

滚动前

向下滚动后出现状态栏

共有1个答案

孔砚
2023-03-14

是否尝试删除工具栏中的app:layout_scrollflags=“ScrollEnteralwaysexituntilcolleded”?我试过这种方法,效果很好

 类似资料:
  • 我最近遇到了协调器布局的问题。当我尝试创建简单的折叠工具栏布局(如本例所示)时,工具栏似乎位于状态栏下,如下图所示(在preLolipop设备上,一切都正常,因为应用程序不会在状态栏下绘制)。 我的活动布局的代码片段: My Styles(仅限21版),其中BaseAppTheme父级为Theme.AppCompat.Light.NoActionBar:

  • 当我做快速挺举时,我有一个CollapsingToolbarLayout的问题。隐藏appBar也会发生同样的事情 我需要工具栏隐藏在滚动和折叠工具栏折叠。当滚动不是很快时,它工作得很好。 但是当它很快的时候——似乎appBar在那之后就崩溃并扩展了。但它没有扩展回来。 请看视频。 折叠工具栏布局 应用程序栏 似乎这个答案是我需要的,但它不起作用。 我的折叠工具栏布局的 xml :

  • 我想在活动中使用appcompat v21工具栏。但我正在实现的工具栏在状态栏下方重叠。我该怎么修? 以下是活动布局xml: 工具栏视图: 主题风格:

  • 我正在尝试在我的android应用程序中实现折叠工具栏。我可以按我希望的方式显示工具栏,但滚动时它不会塌陷。 我正在使用以下代码 activity.xml main_toolbar.xml 下面是屏幕的外观

  • 我知道有成千上万个这样的问题,但是我尝试了所有的方法,但是我不能想出一个解决方案。基本上,我使用的是NoActionBar风格的活动。 风格。xml: v21/风格。xml: 家庭活动正常,抽屉将在透明状态栏下正常打开: 问题是使用以下布局的另一个活动: 基本上,状态栏是透明的,所以我看不到它,因为我的colorPrimary是白色的。奇怪的是,如果我折叠工具栏(因此只有选项卡可见),状态栏将正确

  • 我试着做一个弯曲的折叠工具栏,但是没有白色的角落覆盖我的内容,我成功地创建了视图,但是即使设置AppBarLayout背景为透明,也没有给我透明的边缘