android - 状态栏下方的 CollapsingToolbarLayout 图片

标签 android android-layout

这里的问题是,即使我没有将 fitsSystemWindows="true"设置为 xml 中的任何标记,它仍然看起来好像有 fitsSystemWindows="true"。如果您看不出区别,那就是在状态栏部分。

现在的结果:

This is the result now

我想要什么:

this is what i want

其他详细信息:

  • 我已经在 styles.xml (v21) 中将半透明状态设置为 true

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="false"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">
    
        <ImageView
            android:id="@+id/img"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:fitsSystemWindows="false"
            android:scaleType="fitXY"
            android:src="@drawable/com_facebook_profile_picture_blank_portrait"
            app:layout_collapseMode="parallax" />
    
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:fitsSystemWindows="false"
            android:theme="@style/AppTheme.Toolbar"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/AppTheme.PopupOverlay" />
    
    </android.support.design.widget.CollapsingToolbarLayout>
    

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="a very long text, don't mind this, this is working as intended" />
    

v21/styles.xml

<resources>

<style name="AppTheme" parent="AppTheme.Base">
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

</resources>

样式.xml

<resources>

<style name="AppTheme" parent="AppTheme.Base">

</style>

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.Dark" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorPrimary</item>
</style>

<style name="AppTheme.Toolbar">
    <item name="android:textColorPrimary">@color/white</item>
    <item name="colorControlNormal">@color/white</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

最佳答案

这真的很令人困惑,但在我将 fitsSystemWindows="true" 放入所有标签后,它起作用了。

关于android - 状态栏下方的 CollapsingToolbarLayout 图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34961797/

相关文章:

java - Android NDK JNI 点表示法方法签名变量

java - 如何将文件从 Android 写入 PC 并返回?

android - 如何添加向上滚动时消失(在 ListView 中向下)并向下滚动时出现的 View ?

java - 在第二个 Intent 中刷新数组列表

Android textview 阴影不能使用 style.xml

android - Android应用程序中事件总线可以完全取代Intent吗?

android - 更改 ListView 中项目的颜色 - Android

android - ContextCompat.getColor() 忽略 NightMode

android - 导航组件的 popUpTo 不删除向上按钮

Android 两种布局,两侧宽度固定,一种布局中间宽度可变