Skip to content Skip to sidebar Skip to footer

Fragment With Collapsingtoolbar Showing Activity Toolbar

I have a CollapsingToolbarLayout in my fragment and is showing fine, the thing is that App Toolbar is also being showed. I try this solution: Can I use CollapsingToolbarLayout in a

Solution 1:

Which type of layout are you using in the activity where you are inflating this fragment? Maybe a CoordinatorLayout can solve your problem.

http://developer.android.com/reference/android/support/design/widget/AppBarLayout.html

https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout

Solution 2:

Your fragment replaces the inner layer, but not Acitvity toolbar. That all worked properly should be placed together with fragment container and toolbar. In your code:

<!-- Use this LinearLayout for container --><LinearLayoutandroid:id="@+id/correct_container"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><android.support.v7.widget.Toolbarandroid:id="@+id/appToolbar"android:layout_height="wrap_content"android:layout_width="match_parent"android:minHeight="?attr/actionBarSize"android:background="?attr/colorPrimary"android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"android:popupTheme="@style/ThemeOverlay.AppCompat.Dark"/><!-- Framelayout to display Fragments --><FrameLayoutandroid:id="@+id/frame_container"android:layout_width="match_parent"android:layout_height="match_parent" /></LinearLayout>

Sure we can use another solution. We can create function in MainActivity and call in all fragments for closing actual Toolbar (Perform other code different from yours). And other....

Solution 3:

Change the color to transparent when you switch the your collapsing layout fragment.

Go through this you will get your solution:

https://stackoverflow.com/a/57771274/5328951

Post a Comment for "Fragment With Collapsingtoolbar Showing Activity Toolbar"