Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – Putting multiple views in CollapsingToolbarLayout overlap on one another

Posted on November 11, 2022 By

Solution 1 :

The first draft was without the linearlayout, but doing so the toolbar was overlapping the included layout.

You can go ahead with your first attempt, but just add a top margin that equals to the Toolbar height; which is the default ActionBar height in your case ?attr/actionBarSize.

So, this will be:

<com.google.android.material.appbar.AppBarLayout
    
    <com.google.android.material.appbar.CollapsingToolbarLayout
        
        <com.google.android.material.appbar.MaterialToolbar
            ...
            android_layout_height="?attr/actionBarSize"
         
         <include
            ... 
            android_layout_marginTop="?attr/actionBarSize"
         
...

Problem :

I am trying to include a layout under the toolbar within a CollapsingToolbarLayout.
The first draft was without the linearlayout, but doing so the toolbar was overlapping the included layout.
So I put the toolbar and the layout into a linearlayout. The layout is under the toolbar as intended, but the scrolling behaviour is now gone.
They just stay at the same place and don’t scroll.

<com.google.android.material.appbar.AppBarLayout
        android_id="@+id/appbar"
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_fitsSystemWindows="true"
        app_liftOnScroll="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
            android_id="@+id/toolbar_layout"
            style="@style/Widget.SaltWatcher.App.Toolbar"
            android_layout_width="match_parent"
            android_layout_height="wrap_content"
            app_layout_scrollFlags="scroll|exitUntilCollapsed"
            app_titleEnabled="false"
            app_toolbarId="@id/toolbar">

            <LinearLayout
                android_layout_width="match_parent"
                android_layout_height="wrap_content"
                android_orientation="vertical"
                app_layout_collapseMode="pin"
                app_layout_scrollFlags="scroll|exitUntilCollapsed">

                <com.google.android.material.appbar.MaterialToolbar
                    android_id="@+id/toolbar"
                    style="@style/Widget.SaltWatcher.App.Toolbar"
                    android_layout_width="match_parent"
                    android_layout_height="?attr/actionBarSize"
                    android_elevation="0dp"
                    app_contentInsetStart="0dp"
                    app_elevation="0dp"
                    app_layout_collapseMode="parallax" />

                <include
                    android_id="@+id/values"
                    layout="@layout/layout_values"
                    android_layout_width="match_parent"
                    android_layout_height="136dp"
                    android_layout_gravity="bottom"
                    android_scaleType="centerCrop"
                    app_contentInsetStart="0dp"
                    app_layout_collapseMode="parallax" />
            </LinearLayout>
        </com.google.android.material.appbar.CollapsingToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>

Comments

Comment posted by problem

do you know how solve this

Comment posted by Zain

@vivekmodi This can be done using

Comment posted by vivek modi

any example please. I didn’t know how to do that. It really help me. Thanks

Comment posted by here

@vivekmodi I’m not sure if there is something online about this; but

Comment posted by vivek modi

yes I need something similar, Searchbar when focus it goes to toolbar this is fine for me. But when he swipe down searchbar goes to original position, I only want this when searchdown remove focus.

READ  [FIXED] android - Not able to Update application in play store
Powered by Inline Related Posts

Android Tags:android, android-collapsingtoolbarlayout, android-coordinatorlayout, android-layout, android-toolbar

Post navigation

Previous Post: [FIXED] java – is permission needed when choosing image from gallery on android?
Next Post: [FIXED] Android Java: How to get component in a custom view? (Trying to access components via findByViewId and get null)

Related Posts

[FIXED] java – im using a device for android studio and after a while app crashes and i get this error. anybody knows what the problem is? Android
[FIXED] Use bottomsheet’s action to open another dialogfragment without crashing android navigation component Android
[FIXED] java – Can I trust MQTT when phone in power safe mode Android
[FIXED] arduino – Kotlin: Read bluetooth data real time Android
[FIXED] flutter – Can’t find Open for Editing in Android Studio Android
[FIXED] Sum two variables in Android Studio Java Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Which is stronger 19 gauge or 23 gauge?
  • Does BMW still use GM transmissions?
  • Is primary or secondary market research better?
  • What does it mean when ADT says low battery?
  • Can a baby sleep on a regular mattress?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme