everybody! have fragment in framelayout container within activity, has navigation drawer. fragment has tablayout. , problem is, can see, activity's toolbar drops shadow on fragment's tablayout. dont want place tablayout in activity's appbar layout because won't have access fragment and, moreover, don't need tablayout anywhere else.
this activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.navigationview android:id="@+id/mainnavigationview" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitssystemwindows="true" app:headerlayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" />
and app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/logintoolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" app:layout_scrollflags="scroll|enteralways|snap" app:popuptheme="@style/apptheme.popupoverlay" /> </android.support.design.widget.appbarlayout> <framelayout android:id="@+id/mainfragmentcontainer" android:layout_width="match_parent" android:layout_height="match_parent" /> </linearlayout>
this fragment_by_day_schedule.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical"> <android.support.design.widget.tablayout android:id="@+id/bydaytablayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabbackground="?attr/colorprimary" app:tabmode="scrollable" /> <android.support.v4.view.viewpager android:id="@+id/bydayviewpager" android:layout_width="match_parent" android:layout_height="match_parent" /> </linearlayout>
i want toolbar hide when scroll list in fragment within viewpager
do have ideas how can achive that?
use this. works on projects.
viewcompat.setelevation(mappbarlayout, 0);
and second question how hide toolbar? change parent layout linearlayout 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:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/logintoolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" app:layout_scrollflags="scroll|enteralways|snap" app:popuptheme="@style/apptheme.popupoverlay" /> </android.support.design.widget.appbarlayout> <framelayout android:id="@+id/mainfragmentcontainer" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.design.widget.coordinatorlayout>
after have tell android when toolbar should hide. should tell view can scroll. have add app:layout_behavior="@string/appbar_scrolling_view_behavior"
in viewpager.
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical"> <android.support.design.widget.tablayout android:id="@+id/bydaytablayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabbackground="?attr/colorprimary" app:tabmode="scrollable" /> <android.support.v4.view.viewpager android:id="@+id/bydayviewpager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> </linearlayout>
Comments
Post a Comment