小编Mig*_*tor的帖子

CollapsingToolbarLayout图像位于状态栏下方

这里的问题是,虽然我没有将fitsSystemWindows ="true"设置为xml中的任何标记,但它仍然看起来好像它具有fitsSystemWindows ="true".如果你没有看到差异,它就在状态栏部分.

结果现在:

这是现在的结果

我想要的是 :

这就是我要的

额外细节:

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

    <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>
    
    Run Code Online (Sandbox Code Playgroud)

    <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" />
    
    Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

styles.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> …
Run Code Online (Sandbox Code Playgroud)

android android-layout

3
推荐指数
2
解决办法
4544
查看次数

标签 统计

android ×1

android-layout ×1