android - CoordinatorLayout in combination with CollapsingToolbarLayout, RecyclerView and Fragments issue -
in application have 1 mainactivity witch contains container fragments, 1 fragment - coordinatorfragment cordinatoirlayout+recycleview , collapsingtoolbarlayout , second - simplefragment 1 textview. on create mainactivity add first fragment
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); fragmenttransaction transaction = getfragmentmanager().begintransaction(); fragment fragment = new coordinatorfragment(); transaction.replace(r.id.fragmentcontainer,fragment); transaction.commit(); }
coordinatorfragnet's layout:
<android.support.design.widget.coordinatorlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.appbarlayout android:id="@+id/main_appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#fff" android:fitssystemwindows="true"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/main.collapsing" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#0000" android:fitssystemwindows="true" app:layout_scrollflags="snap|scroll|enteralways"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#0000" android:fitssystemwindows="true" android:orientation="vertical" app:layout_collapsemode="none"> <imageview android:id="@+id/first" android:layout_width="wrap_content" android:layout_height="23dp" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:layout_margintop="30dp" android:adjustviewbounds="true" /> <textview android:id="@+id/second" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:layout_margintop="40dp" /> <textview android:id="@+id/third" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="20dp" android:layout_marginright="20dp" /> <view android:layout_width="match_parent" android:layout_height="130dp" android:layout_margintop="20dp" android:background="#fff" /> </linearlayout> </android.support.design.widget.collapsingtoolbarlayout> <view android:id="@+id/fourth" android:layout_width="match_parent" android:layout_height="10dp" android:background="#fff" app:layout_collapsemode="pin" /> <linearlayout android:id="@+id/fiveth_field" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:background="@color/colorprimary" app:layout_collapsemode="pin"> <textview android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal" android:padding="20dp" android:text="right" /> <textview android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal" android:padding="20dp" android:text="left" /> </linearlayout> </android.support.design.widget.appbarlayout> <android.support.v7.widget.recyclerview android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.coordinatorlayout>
in using recycleeview's adapter replace first fragments second
@override public void onbindviewholder(recyclerview.viewholder holder, int position) { holder.itemview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { getfragmentmanager().begintransaction().replace(r.id.fragmentcontainer, new simplefragment()).addtobackstack("tag").commit(); } }); }
after first initialization ok. can scroll recyclerview content , last item visible.
but after moving second fragment , go first fragment, clicking button, last item of recyclerview cutted on size of not collapse part of toolbar. , there no ability view item. other functionality ok.
scroll last (after fragments replacement , click button)
any ideas how fix issue leaving fragment based implementation? in advance !!
change recyclerview's height match_parent
.
Comments
Post a Comment