I'm trying to put fragments into NestedSrollView. Since it's child of FrameLayout I assume It's possible. This is xml:
<android.support.v4.widget.NestedScrollView
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v4.widget.NestedScrollView>
After first transaction everything is fine, fragment is attached to NestedScrollView:
getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(R.anim.slide_right, R.anim.fade_out, R.anim.slide_left, R.anim.fade_out)
.add(R.id.fragmentContainer, new RankingFragment(), RANKING_FRAGMENT)
.commit();
But then when I want to replace first fragment I get this error:
ScrollView can host only one direct child
Second transaction:
getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(R.anim.slide_right, R.anim.fade_out, R.anim.slide_left, R.anim.fade_out)
.replace(R.id.fragmentContainer, new com.steveq.photoquiz.ui.fragments.PreparationFragment(), PREPARATION_FRAGMENT)
.addToBackStack(PREPARATION_FRAGMENT)
.commit();
Can anyone help with this?
Try to set this attr 'android:fillViewport' as true, then you will find your fragment is attached to activity
<android.support.v4.widget.NestedScrollView
android:id="@+id/feed_club_tab_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/feedui_pager_tab"
android:fillViewport="true"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With