Scroll toolbar along with fragment in a drawer layout - android

I want to scroll tollbar while scrolling fragment in drawer layout.
Below is my xml layouts:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data></data>
<androidx.drawerlayout.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
android:elevation="0dp"
android:keepScreenOn="true"
app:elevation="0dp"
tools:context=".ui.activities.CulpabilityHome">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/llOutertwo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_70sdp"
android:layout_marginBottom="#dimen/_70sdp"
android:background="#color/red"
android:orientation="horizontal"
android:visibility="visible" />
<LinearLayout
android:id="#+id/llOuterone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="#dimen/_10sdp"
android:layout_marginTop="#dimen/_40sdp"
android:layout_marginBottom="#dimen/_40sdp"
android:background="#color/black"
android:orientation="horizontal"
android:visibility="visible" />
<LinearLayout
android:id="#+id/llToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/gray_bg"
android:orientation="vertical">
<include
android:id="#+id/navHeader"
layout="#layout/layout_home_toolbar" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_1sdp"
android:background="#color/gray_bg" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/bottomNavigation"
android:layout_width="match_parent"
android:layout_height="#dimen/_40sdp"
android:layout_gravity="bottom"
android:background="#color/white"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal">
<ImageView
android:id="#+id/home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginEnd="#dimen/_5sdp"
android:layout_weight="0.25"
android:padding="#dimen/_10sdp"
android:src="#mipmap/home"
tools:ignore="RtlCompat" />
<ImageView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_weight="0.25"
android:padding="#dimen/_10sdp"
android:src="#mipmap/map"
tools:ignore="RtlCompat" />
<ImageView
android:id="#+id/myVideo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_weight="0.25"
android:padding="#dimen/_10sdp"
android:src="#drawable/ic_my_video"
tools:ignore="RtlCompat" />
<!-- <ImageView-->
<!-- android:id="#+id/chat"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="#dimen/_5sdp"-->
<!-- android:layout_marginEnd="#dimen/_5sdp"-->
<!-- android:layout_weight="0.25"-->
<!-- android:padding="#dimen/_10sdp"-->
<!-- android:src="#mipmap/chats_icon"-->
<!-- tools:ignore="RtlCompat" />-->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25">
<ImageView
android:id="#+id/notification"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginEnd="#dimen/_5sdp"
android:padding="#dimen/_10sdp"
android:src="#mipmap/notification"
tools:ignore="RtlCompat" />
<TextView
android:id="#+id/txtNotificationCountBadge"
android:layout_width="#dimen/_17sdp"
android:layout_height="#dimen/_17sdp"
android:layout_gravity="top"
android:layout_marginStart="50dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="-5dp"
android:background="#drawable/circle_notification_badge"
android:gravity="center"
android:text="99+"
android:textColor="#android:color/white"
android:textSize="9sp"
android:visibility="gone"
tools:visibility="visible" />
</FrameLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_1sdp"
android:background="#color/gray_bg" />
<FrameLayout
android:id="#+id/home_fram"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
</FrameLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/colorPrimary"
android:fitsSystemWindows="true"
app:elevation="0dp"
app:headerLayout="#layout/nav_header_main"
app:itemBackground="#android:color/transparent"
app:itemIconTint="#color/white"
app:itemTextColor="#color/white"
app:itemVerticalPadding="#dimen/_12sdp"
app:menu="#menu/activity_main_drawer">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical"
android:padding="#dimen/_16sdp">
<TextView
android:id="#+id/txtVersion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/gt_walsheim_pro_light"
android:gravity="start"
android:text="#string/app_version"
android:textColor="#color/white"
android:textSize="#dimen/_10sdp" />
</LinearLayout>
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
</layout>
layout_home_toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways">
<androidx.appcompat.widget.Toolbar
android:id="#+id/mainTool"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="#color/white"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
android:contentInsetEnd="0dp"
android:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/HeaderToolLogo"
android:layout_width="#dimen/_32sdp"
android:layout_height="#dimen/_32sdp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="#dimen/_10sdp"
android:src="#mipmap/culpa_header_icon"
app:civ_border_color="#color/colorPrimary"
app:civ_border_width="#dimen/_1sdp" />
<TextView
android:id="#+id/HeaderToolText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:fontFamily="#font/gt_walsheim_pro_medium"
android:text="#string/home"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/_15ssp" />
<ImageView
android:id="#+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="#dimen/_5sdp"
android:layout_toStartOf="#+id/chat"
android:padding="#dimen/_5sdp"
android:src="#mipmap/search_home"
app:tint="#color/colorPrimary"
tools:ignore="RtlCompat" />
<ImageView
android:id="#+id/chat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginEnd="#dimen/_5sdp"
android:layout_weight="0.25"
android:padding="#dimen/_5sdp"
android:src="#mipmap/chats_icon"
app:tint="#color/colorPrimary"
tools:ignore="RtlCompat" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</LinearLayout>
I want to make toolbar hide while user scroll content like facebook.
I also tried to Appbarlayout but its not working so please help me to solve this issue.
Thanks in advance

Related

CollapsingToolbar, Viewpager having recyclerview and NestedScrollview

Here is xml of my layout having CollapsingToolbar and viewpager. I am using NestedScrollViews so that the CollapsingToolbarLayout, swipetoreferesh and viewpager work smoothly.
<layout 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">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".wallet_staking_survey.ui.survey_main.SurveyMain2Fragment">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:fitsSystemWindows="true"
app:contentScrim="#color/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="#dimen/_260sdp"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="#drawable/bg_kyc_progress_level"
app:layout_collapseMode="parallax" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/_20sdp"
android:orientation="vertical">
<com.realresearch.survey.customviews.DonutProgress
android:id="#+id/levelProgress"
android:layout_width="#dimen/_180sdp"
android:layout_height="#dimen/_180sdp"
android:layout_gravity="center"
app:donut_background_color="#android:color/transparent"
app:donut_circle_starting_degree="270"
app:donut_finished_color="#color/md_light_green_300"
app:donut_finished_stroke_width="5dp"
app:donut_text=""
app:donut_unfinished_color="#color/md_grey_100"
app:donut_unfinished_stroke_width="5dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvLevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/recipekorea"
android:text="#string/level_2"
android:textColor="#android:color/white"
android:textSize="#dimen/_24sdp" />
<LinearLayout
android:id="#+id/llKycLevelProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/tvUpgradKyc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:fontFamily="#font/recipekorea"
android:text="#string/try_updating_your_kyc_level"
android:textColor="#android:color/white"
android:textSize="#dimen/_14sdp" />
<ImageView
android:id="#+id/ivHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:layout_marginStart="#dimen/_4sdp"
android:src="#drawable/ic_baseline_help_24"
android:text="#string/try_updating_your_kyc_level"
android:textColor="#android:color/white"
android:textSize="#dimen/_14sdp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<androidx.cardview.widget.CardView
android:id="#+id/cv_wallet_balance"
android:layout_width="match_parent"
android:layout_height="#dimen/_60sdp"
android:layout_marginStart="#dimen/_30sdp"
android:layout_marginTop="#dimen/_230sdp"
android:layout_marginEnd="#dimen/_30sdp"
android:layout_marginBottom="#dimen/_10sdp"
app:cardCornerRadius="#dimen/_35sdp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:fontFamily="#font/recipekorea"
android:text="#string/my_tnc"
android:textColor="#color/textColor"
android:textSize="#dimen/_16sdp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/title">
<TextView
android:id="#+id/tvMyTNCBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/recipekorea"
android:gravity="center"
android:text="10,000"
android:textColor="#color/pinkRed"
android:textSize="#dimen/_20sdp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:fontFamily="#font/recipekorea"
android:text="#string/tnc"
android:textColor="#color/md_grey_400" />
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<!--- ADD TAB_LAYOUT HERE-->
<com.google.android.material.tabs.TabLayout
android:id="#+id/surveyTabs"
android:layout_width="match_parent"
android:layout_height="40dp"
android:fillViewport="true"
app:tabGravity="fill"
app:tabMode="scrollable" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:clipToPadding="false"
android:fillViewport="true"
android:isScrollContainer="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/swipe_to_refresh"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.core.widget.NestedScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:fillViewport="true"
android:isScrollContainer="false">
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/surveyFilterPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
I am using single fragment having a recyclerview to show three fragments in viewpager i.e. FragmentA, FragmentB, and FragmentC. Now the problem is FragmentB takes height equals to the content of FragmentA resulting in empty scrollable spaces in FragmentB. Same is the case with FragmentC. Below is the xml of my Fragment having recyclerview.
<layout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="3">
<LinearLayout
android:id="#+id/ll_no_survey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/_50sdp"
android:gravity="center"
android:visibility="gone"
android:orientation="vertical">
<ImageView
android:layout_width="#dimen/_60sdp"
android:layout_height="#dimen/_60sdp"
android:src="#drawable/ic_info" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:fontFamily="#font/open_sans_semi_bold"
android:text="#string/no_survey_response"
android:textColor="#color/defaultTextColor"
android:textSize="17.3sp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/survey_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="visible" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="#font/open_sans_semi_bold"
android:text="#string/all_surveys"
android:textColor="#color/c_0078AB"
android:textSize="17.3sp"
android:visibility="gone" />
</RelativeLayout>
</layout>
Please help me as i am not able to find any solution.
The second NestedScrollView seems to be unnecessary, you can try something like the following codes:
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:fitsSystemWindows="true"
app:contentScrim="#color/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="#dimen/_260sdp"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/_20sdp"
android:orientation="vertical">
<com.realresearch.survey.customviews.DonutProgress
android:id="#+id/levelProgress"
app:donut_background_color="#android:color/transparent"
app:donut_circle_starting_degree="270"
app:donut_finished_color="#color/md_light_green_300"
app:donut_finished_stroke_width="5dp"
app:donut_text=""
app:donut_unfinished_color="#color/md_grey_100"
app:donut_unfinished_stroke_width="5dp"
android:layout_width="#dimen/_180sdp"
android:layout_height="#dimen/_180sdp"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvLevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="level_2"
android:textColor="#android:color/white"
android:textSize="#dimen/_24sdp" />
<LinearLayout
android:id="#+id/llKycLevelProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/tvUpgradKyc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:text="try_updating_your_kyc_level"
android:textColor="#android:color/white"
android:textSize="#dimen/_14sdp" />
<ImageView
android:id="#+id/ivHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_4sdp"
android:layout_marginTop="#dimen/_5sdp"
android:src="#drawable/ic_baseline_help_24"
android:text="try_updating_your_kyc_level"
android:textColor="#android:color/white"
android:textSize="#dimen/_14sdp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<androidx.cardview.widget.CardView
android:id="#+id/cv_wallet_balance"
android:layout_width="match_parent"
android:layout_height="#dimen/_60sdp"
android:layout_marginStart="#dimen/_30sdp"
android:layout_marginTop="#dimen/_230sdp"
android:layout_marginEnd="#dimen/_30sdp"
android:layout_marginBottom="#dimen/_10sdp"
app:cardCornerRadius="#dimen/_35sdp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="my_tnc"
android:textSize="#dimen/_16sdp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/title">
<TextView
android:id="#+id/tvMyTNCBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="10,000"
android:textSize="#dimen/_20sdp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:text="tnc" />
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<!--- ADD TAB_LAYOUT HERE-->
<com.google.android.material.tabs.TabLayout
android:id="#+id/surveyTabs"
android:layout_width="match_parent"
android:layout_height="40dp"
android:fillViewport="true"
app:tabGravity="fill"
app:tabMode="scrollable" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/swipe_to_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.core.widget.NestedScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/surveyFilterPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

How To Hide AppBar When Scrolling Down

I have an AppBar and other things in my layout. When the user scrolls down, I want AppBar(actually, the Toolbar to hide. This is what I have tried, the app bar isn't hiding all small part it just stays there. Actually I think the problem is with my header of the screen it gets collapsed and adds a small space when I scroll.
As you can see in second image some part stays it doesn't hide. I need to hide that part while scrolling.
Please provide me solution what am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="#style/TextAppearance.AppCompat.Title"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/slideIV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/ic_dish" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottomButtonRL"
android:layout_gravity="bottom"
android:background="#drawable/gradient_bg" />
<View style="#style/itemBottomViewLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="#dimen/_20"
android:gravity="center_vertical"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/fake_chef_bg"
app:civ_border_color="#color/border_grey_color"
app:civ_border_width="#dimen/_2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_5"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/bold_font"
android:text="#string/fatima_al_zahraa"
android:textColor="#color/white"
android:textSize="#dimen/large_text_size"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="#font/regular_font"
android:text="#string/presenter_of_the_cuient"
android:textColor="#color/white"
android:textSize="#dimen/app_text_size" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/bottomButtonRL"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/slideIV"
android:layout_marginTop="-25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_0"
android:layout_weight="1" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_0"
android:layout_weight="1"
android:background="#color/defaultColor" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="#dimen/_20"
android:paddingLeft="#dimen/_20">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/ic_share" />
<RelativeLayout
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_10"
android:layout_marginLeft="#dimen/_10"
android:background="#drawable/ic_rec1">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/regular_font"
android:gravity="center"
android:layout_centerInParent="true"
android:text="#string/add_to_fav"
android:textColor="#color/white"
android:textSize="#dimen/medium_text_size" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bottom_radius_view">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/regular_font"
android:padding="#dimen/_20"
android:text="#string/galetes_fires_au_plates_fires_au_plates_fires_au_plates_fires_au_plates_fires_au_plates"
android:textColor="#color/white"
android:textSize="#dimen/app_text_size" />
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.Toolbar
android:visibility="gone"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="#dimen/_20"
android:paddingTop="#dimen/_10"
android:paddingRight="#dimen/_20">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/bold_font"
android:padding="#dimen/_5"
android:text="#string/les_videos"
android:textColor="#color/medium_grey_text_color"
android:textSize="#dimen/large_text_size" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/itemFRV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_5" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
This is the header code:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/header_height"
android:background="#color/white"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="#dimen/_20"
android:paddingRight="#dimen/_20">
<LinearLayout
android:id="#+id/backLL"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:gravity="center"
android:paddingRight="#dimen/_20"
android:layout_marginBottom="#dimen/_10"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/ic_back" />
</LinearLayout>
<ImageView
android:id="#+id/logoIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:adjustViewBounds="true"
android:paddingStart="0dp"
android:paddingTop="#dimen/_15"
android:paddingEnd="#dimen/_10"
android:layout_marginBottom="#dimen/_10"
android:src="#drawable/ic_header_logo" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/profileIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:adjustViewBounds="true"
android:paddingStart="#dimen/_10"
android:paddingTop="#dimen/_15"
android:paddingEnd="0dp"
android:layout_marginBottom="#dimen/_10"
android:src="#drawable/ic_default_user" />
</LinearLayout>
</layout>
Answer to the problem is just remove
android:fitsSystemWindows="true"
Change the layout_scrollFlags
app:layout_scrollFlags="scroll|exitUntilCollapsed"
replace above line with
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"

How can I add top drawer and bottom navigation in android activity?

How to add top drawer and bottom tab navigation in whole application?
I tried to combine 2 activity in android studio and its causing design issue. Its not working
For the bottom navigation
https://developer.android.com/reference/android/support/design/widget/BottomNavigationView
For Top drawer exaplain a little what exactly you want
You can achieve this throughout your whole Project in this way.
Use this as an activity_main.xml like as your MainActivity.java class.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_home"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="#dimen/dp_180"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/top_lay"
android:layout_width="match_parent"
android:layout_height="#dimen/nav_header_height"
android:background="#color/colorPrimary"
android:orientation="vertical"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<RelativeLayout
android:id="#+id/userimageLay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<com.team.helperclasses.CircleImageView
android:id="#+id/userimage"
android:layout_width="#dimen/dp_100"
android:layout_height="#dimen/dp_100"
android:src="#mipmap/side_menu_profile_"
app:civ_border_color="#color/colorPrimary"
app:civ_border_overlay="true"
app:civ_border_width="1dp" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/editProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/top_lay"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/editProfileText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/editProfileImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/editProfile"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/editProfileImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/side_menu_profile" />
</RelativeLayout>
<View
android:id="#+id/editProfiledivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/editProfile"
android:background="#color/light_black" />
<RelativeLayout
android:id="#+id/sharedWall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/editProfile"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/sharedWallText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/shareWallImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/sharedWall"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/shareWallImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/wall" />
</RelativeLayout>
<View
android:id="#+id/shareWallDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/sharedWall"
android:background="#color/light_black" />
<RelativeLayout
android:id="#+id/changeLang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/shareWallDivider"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/changeLangText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/changeLangImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/changeLanguage"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/changeLangImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/language" />
</RelativeLayout>
<View
android:id="#+id/changeLangdivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/changeLang"
android:background="#color/light_black" />
<RelativeLayout
android:id="#+id/logout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/changeLangdivider"
android:paddingBottom="#dimen/dp_5"
android:paddingTop="#dimen/dp_5">
<TextView
android:id="#+id/logoutText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/logoutImage"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/dp_8"
android:text="#string/logout"
android:textColor="#color/dull_black"
android:textSize="#dimen/sp_18" />
<ImageView
android:id="#+id/logoutImage"
android:layout_width="#dimen/dp_45"
android:layout_height="#dimen/dp_45"
android:layout_centerHorizontal="true"
android:src="#mipmap/log_out" />
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
& the Layout app_bar_home.xml looks like this.
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.team.activities.Home">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:title="#string/app_name"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:theme="#style/ToolBarStyle">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/search"
android:gravity="left"
android:text="#string/app_name"
android:textColor="#color/black"
android:textSize="#dimen/sp_22" />
<ImageView
android:id="#+id/searchHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/notificationLay"
android:src="#mipmap/search" />
<RelativeLayout
android:id="#+id/notificationLay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/dp_5">
<ImageView
android:id="#+id/notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/dp_5"
android:src="#mipmap/notification" />
<ImageView
android:id="#+id/notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/notification"
android:padding="#dimen/dp_5"
android:src="#drawable/counter_bg" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_home" />
</android.support.design.widget.CoordinatorLayout>
& content_home.xml in which you can define the things as per your requirement in the application.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/content_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.team.activities.Home"
tools:showIn="#layout/app_bar_home">
<RelativeLayout
android:id="#+id/fragment_space"
android:name="com.presence.fragments.HomeFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_lay" />
<LinearLayout
android:id="#+id/bottom_lay"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_50"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="#color/colorPrimary"
android:layoutDirection="ltr"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/tab_create"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_create"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_create"
android:layout_centerHorizontal="true"
android:src="#mipmap/create" />
<TextView
android:id="#+id/text_create"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/create"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab_received"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_received"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_received"
android:layout_centerHorizontal="true"
android:src="#mipmap/recived" />
<TextView
android:id="#+id/text_received"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/received"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab_sent"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_sent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_sent"
android:layout_centerHorizontal="true"
android:src="#mipmap/sent" />
<TextView
android:id="#+id/text_sent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/sent"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab_website"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/image_website"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/text_travel"
android:layout_centerHorizontal="true"
android:src="#mipmap/web" />
<TextView
android:id="#+id/text_travel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/booking"
android:textColor="#color/white"
android:textSize="#dimen/sp_10" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Try this hope it helps you.

BottomNavigationView is not showing

When i add the background item in my theme than the BottomNavigationView is disappear.
#color/primary_red
#color/primary_red
and bottomnavigationview
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
design:menu="#menu/bottom_menu_bar" />
When I remove the background item from the theme then it looks like
there is blank space between the window and bottom bar. And also background text is also appearing in foreground. How to remove that.
edit
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:design="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="RtlHardcoded"
android:background="#color/primary_background"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.design.widget.AppBarLayout
android:scrollbars="none"
android:id="#+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
//some code_1
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.Toolbar
android:visibility="invisible"
android:id="#+id/main.toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_anchor="#id/main.framelayout.title"
app:theme="#style/ThemeOverlay.AppCompat.Dark"
app:title="Dashboard">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<Space
android:layout_width="60dp"
android:layout_height="60dp"
/>
<TextView
android:id="#+id/main.textview.title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:gravity="center_vertical"
android:text="#string/user_name_demp"
android:textColor="#android:color/white"
android:textSize="20sp"
/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<ImageView
android:layout_marginBottom="#dimen/activity_horizontal_margin"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:background="#drawable/circle"
android:id="#+id/profile_pic"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="left"
app:layout_behavior="profile.AvatarImageBehavior"
app:finalHeight="32dp"
app:finalYPosition="2dp"
app:startHeight="15dp"
app:startToolbarPosition="10dp"
app:startXPosition="10dp"/>
<android.support.design.widget.BottomNavigationView
android:background="#color/green"
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
design:menu="#menu/bottom_menu_bar" />
<android.support.v4.widget.NestedScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_marginTop="#dimen/activity_horizontal_margin"
android:textStyle="bold"
android:textAlignment="center"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:textColor="#color/primary_text"
android:text="#string/health_vitals"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:background="#color/primary_text"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--First Sub Block-->
<LinearLayout
android:layout_weight="1"
android:layout_marginRight="1sp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<customView.healthVitalBlockDashboard
android:id="#+id/bp_block"
android:layout_width="match_parent"
android:layout_height="match_parent">
</customView.healthVitalBlockDashboard>
</LinearLayout>
<!--Second Sub Block-->
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<customView.healthVitalBlockDashboard
android:id="#+id/bsl_block"
android:layout_width="match_parent"
android:layout_height="match_parent">
</customView.healthVitalBlockDashboard>
</LinearLayout>
</LinearLayout>
<TextView
android:paddingTop="#dimen/activity_horizontal_margin"
android:layout_marginBottom="1dp"
android:gravity="center"
android:textColor="#color/primary_text"
android:textStyle="bold"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Medium"
android:text="#string/reminder"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="#+id/medicine_list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<TextView
android:paddingTop="8dp"
android:paddingBottom="22dp"
android:id="#+id/reminderWarning"
android:visibility="gone"
android:gravity="center"
android:textColor="#color/primary_text"
android:textStyle="bold"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
android:text="#string/reminder_warning"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:paddingTop="#dimen/activity_horizontal_margin"
android:layout_marginBottom="1dp"
android:id="#+id/adherence_text"
android:textStyle="bold"
android:textAlignment="center"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
android:textColor="#color/primary_text"
android:text="#string/adherence"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:background="#color/primary_text"
android:layout_below="#+id/adherence_text"
android:id="#+id/action_with_adherence"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<TextView
android:paddingTop="8dp"
android:paddingBottom="22dp"
android:id="#+id/adherence_warning"
android:visibility="gone"
android:gravity="center"
android:textColor="#color/primary_text"
android:textStyle="bold"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Any leads will be helpfull!!!
i am using this code and it works well, try to change yours as your project matches.
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/navigation"/>

Android AppBarLayout height more than screen height

I am trying to create something like this
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
<FrameLayout
android:id="#+id/frameAdvertiseSlider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_scrollFlags="scroll|snap">
<android.support.v4.view.ViewPager
android:id="#+id/viewPagerAdvertiseSlider"
android:layout_width="match_parent"
android:layout_height="#dimen/pager_advertise_slider_height"
android:layout_gravity="top" />
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicatorAdvertiseSlider"
style="#style/IntroPageIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="#dimen/margin_medium" />
</FrameLayout>
<LinearLayout
android:id="#+id/linearLayoutMainCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_mini_small"
android:orientation="horizontal"
app:layout_scrollFlags="scroll|snap">
<Button
android:id="#+id/buttonMainCategory1"
style="#style/ButtonHomeStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableTop="#drawable/ic_category"
android:paddingBottom="12dp"
android:paddingTop="15dp"
android:text="#string/home_category_category" />
<Button
android:id="#+id/buttonMainCategory2"
style="#style/ButtonHomeStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginStart="1dp"
android:layout_weight="1"
android:drawablePadding="5dp"
android:drawableTop="#drawable/ic_action"
android:paddingTop="15dp"
android:text="#string/home_category_action" />
<Button
android:id="#+id/buttonMainCategory3"
style="#style/ButtonHomeStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginStart="1dp"
android:layout_weight="1"
android:drawablePadding="5dp"
android:drawableTop="#drawable/ic_new"
android:paddingTop="15dp"
android:text="#string/home_category_new" />
<Button
android:id="#+id/buttonMainCategory4"
style="#style/ButtonHomeStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginStart="1dp"
android:layout_weight="1"
android:drawablePadding="5dp"
android:drawableTop="#drawable/ic_most_selling"
android:paddingTop="5dp"
android:text="#string/home_category_most_selling" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayoutBanners"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_mini_small"
android:layout_marginTop="#dimen/margin_mini_small"
android:orientation="horizontal"
app:layout_scrollFlags="scroll|snap">
<ImageView
android:id="#+id/imageBanner1"
android:layout_width="0dp"
android:layout_height="#dimen/banner1_height"
android:layout_weight="1"
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="#dimen/banner1_height"
android:layout_marginLeft="1dp"
android:layout_marginStart="1dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="#+id/imageBanner2"
android:layout_width="match_parent"
android:layout_height="#dimen/banner2_height"
android:scaleType="fitXY" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#00000000" />
<ImageView
android:id="#+id/imageBanner3"
android:layout_width="match_parent"
android:layout_height="#dimen/banner2_height"
android:scaleType="fitXY" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_scrollFlags="scroll|snap"
android:layout_marginBottom="#dimen/margin_mini_small">
<android.support.design.widget.TabLayout
android:id="#+id/tabLayoutNews"
android:layout_width="match_parent"
android:layout_height="#dimen/tabs_height"
android:background="#color/white"
app:tabIndicatorColor="#color/main_color"
app:tabMode="fixed"
app:tabSelectedTextColor="#color/home_tab_color"
app:tabTextColor="#color/home_tab_color" />
<android.support.v4.view.ViewPager
android:id="#+id/viewPagerNews"
android:layout_width="match_parent"
android:layout_height="#dimen/news_pager_height"/>
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.design.widget.TabLayout
android:id="#+id/tabLayoutPager"
android:layout_width="match_parent"
android:layout_height="#dimen/tabs_height"
android:background="#color/white"
app:tabGravity="center"
app:tabIndicatorColor="#color/main_color"
app:tabMode="scrollable"
app:tabSelectedTextColor="#color/home_tab_color"
app:tabTextColor="#color/home_tab_color" />
<android.support.v4.view.ViewPager
android:id="#+id/viewPagerTabs"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="#drawable/home_profile_background" />
<LinearLayout
android:id="#+id/linearProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_medium"
android:orientation="vertical">
<rs.netlink.android.widgets.CircleImageView
android:id="#+id/circleImageViewProfile"
android:layout_width="#dimen/profile_image_size"
android:layout_height="#dimen/profile_image_size"
android:scaleType="centerCrop"
android:src="#drawable/default_profile_image"
app:border_color="#color/home_profile_image_ellipse"
app:border_width="1dp" />
<TextView
android:id="#+id/textName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_small_medium"
android:textColor="#color/home_profile_image_ellipse"
android:textSize="#dimen/text_small_normal" />
<TextView
android:id="#+id/textEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_mini_small"
android:textColor="#color/home_profile_image_ellipse"
android:textSize="#dimen/text_micro_mini" />
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/margin_small">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<Button
android:id="#+id/buttonMenuHome"
style="#style/ButtonHomeMenuBorderlessWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_menu_home"
android:drawableStart="#drawable/ic_menu_home"
android:text="#string/menu_home" />
<Button
android:id="#+id/buttonMenuProfile"
style="#style/ButtonHomeMenuBorderlessWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_menu_profile"
android:drawableStart="#drawable/ic_menu_profile"
android:text="#string/menu_profile" />
<Button
android:id="#+id/buttonMenuBasket"
style="#style/ButtonHomeMenuBorderlessWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_menu_basket"
android:drawableStart="#drawable/ic_menu_basket"
android:text="#string/menu_basket" />
<Button
android:id="#+id/buttonMenuWishList"
style="#style/ButtonHomeMenuBorderlessWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_menu_wish_list"
android:drawableStart="#drawable/ic_menu_wish_list"
android:text="#string/menu_wish_list" />
<Button
android:id="#+id/buttonMenuWhereToBay"
style="#style/ButtonHomeMenuBorderlessWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_where_to_bay"
android:drawableStart="#drawable/ic_where_to_bay"
android:text="#string/menu_where_to_buy" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/home_menu_separator_line" />
<Button
android:id="#+id/buttonMenuSettings"
style="#style/ButtonHomeMenuBorderlessWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_menu_settings"
android:drawableStart="#drawable/ic_menu_settings"
android:text="#string/menu_settings" />
<Button
android:id="#+id/buttonMenuCallCenter"
style="#style/ButtonHomeMenuBorderlessWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_call_center"
android:drawableStart="#drawable/ic_call_center"
android:text="#string/menu_call_centar" />
<Button
android:id="#+id/buttonMenuAboutUs"
style="#style/ButtonHomeMenuBorderlessWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_about_us"
android:drawableStart="#drawable/ic_about_us"
android:text="#string/menu_about_us" />
<Button
android:id="#+id/buttonMenuTerms"
style="#style/ButtonHomeMenuBorderlessWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_terms"
android:drawableStart="#drawable/ic_terms"
android:text="#string/menu_terms" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</android.support.design.widget.NavigationView>
When I try this content in AppBarLayout is showed how much is screen height. When I set DrawerLayout android:layout_height="wrap_content" it does not work. How to resolve this.
Thanks.
You would want the closing tag </android.support.design.widget.AppBarLayout> after the include toolbar and not where you have it after a linear layout. The way you have it is including most of what you define here in your AppBarLayout instead of below it, which is not what I think you are try to do.

Categories

Resources