Last active
October 12, 2023 18:29
-
-
Save appoll/d863a09f25076061e881 to your computer and use it in GitHub Desktop.
Working sample of fragment inside CoordinatorLayout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/main_content" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<android.support.design.widget.AppBarLayout | |
android:id="@+id/appbar" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> | |
<android.support.v7.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
android:background="?attr/colorPrimary" | |
app:layout_scrollFlags="scroll|enterAlways" | |
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> | |
</android.support.design.widget.AppBarLayout> | |
<fragment | |
android:id="@+id/some_fragment" | |
android:name="de.no.no.fragments.SomeFragment" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:layout="@layout/some_fragment" | |
app:layout_behavior="@string/appbar_scrolling_view_behavior" | |
/> | |
</android.support.design.widget.CoordinatorLayout> |
@LuizGadao the fragment must be inside a nestesscrollview... or a framelayout, w/ app:layout_behaviour in it.
Working for me
not working
wrapping in the nestedScrollview helps !!
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<fragment
android:id="@+id/home_fragment"
android:name="de.no.no.fragments.SomeFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.core.widget.NestedScrollView>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fragment layout behavior not work.