Why is CollapsingToolbarLayout putting a empty space under expanded content












0















I am trying to use CollapsingToolbarLayout but getting this blue space under my content. Collapsed state doesn't have this problem.





The Empty space under the expanded content seems to be equal to status bar height. I am unable to understand why that would happen.
My xml looks like this



    <android.support.design.widget.CoordinatorLayout
android:fitsSystemWindows="true" ...>

<android.support.design.widget.AppBarLayout
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true" ...>

<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed|enterAlwaysCollapsed"
app:statusBarScrim="@android:color/transparent">

<android.support.constraint.ConstraintLayout
android:id="@+id/expanded_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax".../>

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:navigationIcon="?attr/homeAsUpIndicator"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<android.support.constraint.ConstraintLayout.../>
</android.support.v7.widget.Toolbar>

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


Update



I found a workaround for the time being



collapsingToolbar.post {
val params = (collapsingToolbar.layoutParams as ViewGroup.MarginLayoutParams)
params.height = findViewById<View>(R.id.expanded_toolbar).height
collapsingToolbar.layoutParams = params
}









share|improve this question

























  • Remove app:contentScrim="@color/colorPrimary" in CollapseToolbar and test it still remain or not

    – Ali Khaki
    Nov 20 '18 at 12:10






  • 1





    Doesn't help. It makes the collapsed state toolbar's background color transparent with expanded state content under it. @AliKhaki

    – Rishabh876
    Nov 20 '18 at 12:19


















0















I am trying to use CollapsingToolbarLayout but getting this blue space under my content. Collapsed state doesn't have this problem.





The Empty space under the expanded content seems to be equal to status bar height. I am unable to understand why that would happen.
My xml looks like this



    <android.support.design.widget.CoordinatorLayout
android:fitsSystemWindows="true" ...>

<android.support.design.widget.AppBarLayout
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true" ...>

<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed|enterAlwaysCollapsed"
app:statusBarScrim="@android:color/transparent">

<android.support.constraint.ConstraintLayout
android:id="@+id/expanded_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax".../>

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:navigationIcon="?attr/homeAsUpIndicator"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<android.support.constraint.ConstraintLayout.../>
</android.support.v7.widget.Toolbar>

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


Update



I found a workaround for the time being



collapsingToolbar.post {
val params = (collapsingToolbar.layoutParams as ViewGroup.MarginLayoutParams)
params.height = findViewById<View>(R.id.expanded_toolbar).height
collapsingToolbar.layoutParams = params
}









share|improve this question

























  • Remove app:contentScrim="@color/colorPrimary" in CollapseToolbar and test it still remain or not

    – Ali Khaki
    Nov 20 '18 at 12:10






  • 1





    Doesn't help. It makes the collapsed state toolbar's background color transparent with expanded state content under it. @AliKhaki

    – Rishabh876
    Nov 20 '18 at 12:19
















0












0








0








I am trying to use CollapsingToolbarLayout but getting this blue space under my content. Collapsed state doesn't have this problem.





The Empty space under the expanded content seems to be equal to status bar height. I am unable to understand why that would happen.
My xml looks like this



    <android.support.design.widget.CoordinatorLayout
android:fitsSystemWindows="true" ...>

<android.support.design.widget.AppBarLayout
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true" ...>

<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed|enterAlwaysCollapsed"
app:statusBarScrim="@android:color/transparent">

<android.support.constraint.ConstraintLayout
android:id="@+id/expanded_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax".../>

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:navigationIcon="?attr/homeAsUpIndicator"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<android.support.constraint.ConstraintLayout.../>
</android.support.v7.widget.Toolbar>

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


Update



I found a workaround for the time being



collapsingToolbar.post {
val params = (collapsingToolbar.layoutParams as ViewGroup.MarginLayoutParams)
params.height = findViewById<View>(R.id.expanded_toolbar).height
collapsingToolbar.layoutParams = params
}









share|improve this question
















I am trying to use CollapsingToolbarLayout but getting this blue space under my content. Collapsed state doesn't have this problem.





The Empty space under the expanded content seems to be equal to status bar height. I am unable to understand why that would happen.
My xml looks like this



    <android.support.design.widget.CoordinatorLayout
android:fitsSystemWindows="true" ...>

<android.support.design.widget.AppBarLayout
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true" ...>

<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed|enterAlwaysCollapsed"
app:statusBarScrim="@android:color/transparent">

<android.support.constraint.ConstraintLayout
android:id="@+id/expanded_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax".../>

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:navigationIcon="?attr/homeAsUpIndicator"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<android.support.constraint.ConstraintLayout.../>
</android.support.v7.widget.Toolbar>

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


Update



I found a workaround for the time being



collapsingToolbar.post {
val params = (collapsingToolbar.layoutParams as ViewGroup.MarginLayoutParams)
params.height = findViewById<View>(R.id.expanded_toolbar).height
collapsingToolbar.layoutParams = params
}






android material-design android-toolbar android-collapsingtoolbarlayout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 12:50







Rishabh876

















asked Nov 20 '18 at 12:00









Rishabh876Rishabh876

467323




467323













  • Remove app:contentScrim="@color/colorPrimary" in CollapseToolbar and test it still remain or not

    – Ali Khaki
    Nov 20 '18 at 12:10






  • 1





    Doesn't help. It makes the collapsed state toolbar's background color transparent with expanded state content under it. @AliKhaki

    – Rishabh876
    Nov 20 '18 at 12:19





















  • Remove app:contentScrim="@color/colorPrimary" in CollapseToolbar and test it still remain or not

    – Ali Khaki
    Nov 20 '18 at 12:10






  • 1





    Doesn't help. It makes the collapsed state toolbar's background color transparent with expanded state content under it. @AliKhaki

    – Rishabh876
    Nov 20 '18 at 12:19



















Remove app:contentScrim="@color/colorPrimary" in CollapseToolbar and test it still remain or not

– Ali Khaki
Nov 20 '18 at 12:10





Remove app:contentScrim="@color/colorPrimary" in CollapseToolbar and test it still remain or not

– Ali Khaki
Nov 20 '18 at 12:10




1




1





Doesn't help. It makes the collapsed state toolbar's background color transparent with expanded state content under it. @AliKhaki

– Rishabh876
Nov 20 '18 at 12:19







Doesn't help. It makes the collapsed state toolbar's background color transparent with expanded state content under it. @AliKhaki

– Rishabh876
Nov 20 '18 at 12:19














1 Answer
1






active

oldest

votes


















0














I think you should try changing the layout_height of your collapsing toolbar to wrap_content instead of match_parent



I believe that the blue color is because of the toolbar within the collapsing toolbar. So you should make sure that your background is applied to the appbar layout, or the collapsing toolbar layout.



However, that may cause problems since you're using an image background instead of just a color. So I recommend that you keep track of the collapsing toolbar's status, whether it's collapsed or open, and update your background accordingly.






share|improve this answer


























  • Already tried. wrap_content doesn't change anything.

    – Rishabh876
    Nov 20 '18 at 12:14











  • This could be a good reference for what you're doing youtube.com/watch?v=BTYuLho5_rE

    – Rick
    Nov 20 '18 at 12:19











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53392569%2fwhy-is-collapsingtoolbarlayout-putting-a-empty-space-under-expanded-content%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I think you should try changing the layout_height of your collapsing toolbar to wrap_content instead of match_parent



I believe that the blue color is because of the toolbar within the collapsing toolbar. So you should make sure that your background is applied to the appbar layout, or the collapsing toolbar layout.



However, that may cause problems since you're using an image background instead of just a color. So I recommend that you keep track of the collapsing toolbar's status, whether it's collapsed or open, and update your background accordingly.






share|improve this answer


























  • Already tried. wrap_content doesn't change anything.

    – Rishabh876
    Nov 20 '18 at 12:14











  • This could be a good reference for what you're doing youtube.com/watch?v=BTYuLho5_rE

    – Rick
    Nov 20 '18 at 12:19
















0














I think you should try changing the layout_height of your collapsing toolbar to wrap_content instead of match_parent



I believe that the blue color is because of the toolbar within the collapsing toolbar. So you should make sure that your background is applied to the appbar layout, or the collapsing toolbar layout.



However, that may cause problems since you're using an image background instead of just a color. So I recommend that you keep track of the collapsing toolbar's status, whether it's collapsed or open, and update your background accordingly.






share|improve this answer


























  • Already tried. wrap_content doesn't change anything.

    – Rishabh876
    Nov 20 '18 at 12:14











  • This could be a good reference for what you're doing youtube.com/watch?v=BTYuLho5_rE

    – Rick
    Nov 20 '18 at 12:19














0












0








0







I think you should try changing the layout_height of your collapsing toolbar to wrap_content instead of match_parent



I believe that the blue color is because of the toolbar within the collapsing toolbar. So you should make sure that your background is applied to the appbar layout, or the collapsing toolbar layout.



However, that may cause problems since you're using an image background instead of just a color. So I recommend that you keep track of the collapsing toolbar's status, whether it's collapsed or open, and update your background accordingly.






share|improve this answer















I think you should try changing the layout_height of your collapsing toolbar to wrap_content instead of match_parent



I believe that the blue color is because of the toolbar within the collapsing toolbar. So you should make sure that your background is applied to the appbar layout, or the collapsing toolbar layout.



However, that may cause problems since you're using an image background instead of just a color. So I recommend that you keep track of the collapsing toolbar's status, whether it's collapsed or open, and update your background accordingly.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 12:16

























answered Nov 20 '18 at 12:11









RickRick

8210




8210













  • Already tried. wrap_content doesn't change anything.

    – Rishabh876
    Nov 20 '18 at 12:14











  • This could be a good reference for what you're doing youtube.com/watch?v=BTYuLho5_rE

    – Rick
    Nov 20 '18 at 12:19



















  • Already tried. wrap_content doesn't change anything.

    – Rishabh876
    Nov 20 '18 at 12:14











  • This could be a good reference for what you're doing youtube.com/watch?v=BTYuLho5_rE

    – Rick
    Nov 20 '18 at 12:19

















Already tried. wrap_content doesn't change anything.

– Rishabh876
Nov 20 '18 at 12:14





Already tried. wrap_content doesn't change anything.

– Rishabh876
Nov 20 '18 at 12:14













This could be a good reference for what you're doing youtube.com/watch?v=BTYuLho5_rE

– Rick
Nov 20 '18 at 12:19





This could be a good reference for what you're doing youtube.com/watch?v=BTYuLho5_rE

– Rick
Nov 20 '18 at 12:19




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53392569%2fwhy-is-collapsingtoolbarlayout-putting-a-empty-space-under-expanded-content%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?