Fragment container code is below, which access my home layout which has Nested scroll view which is not scrolling under the appbar layout.
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:com.facebook.shimmer="http://schemas.android.com/tools"
xmlns:shimmer="http://schemas.android.com/apk/res-auto"
android:id="#+id/nav_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--fragment container for all the layouts to be inflated-->
<FrameLayout
android:id="#+id/frag_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
</FrameLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavdrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/white"
app:menu="#menu/bottom_menu" />
<com.wang.avi.AVLoadingIndicatorView
android:id="#+id/loading_bar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:visibility="gone"
app:indicator="LineScaleParty"
app:indicator_color="#F53700" />
</RelativeLayout>
<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:fitsSystemWindows="true"
app:headerLayout="#layout/drawer_header"
app:menu="#menu/drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
Here below is the code for my Main layout inflating in the above layout #+id/frag_container
But the problem is Nested scroll view in my below main layout is not scrolling under the app bar layout, please provide a solution
<androidx.coordinatorlayout.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/mainlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/mountain_green"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="#color/color_white"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlways"
app:scrimAnimationDuration="0">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/toolbarconstraint"
android:layout_width="match_parent"
android:layout_height="140dp"
android:background="#color/color_white"
android:backgroundTint="#color/mountain_green"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/poppinstext"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dp"
android:autoSizeTextType="uniform"
android:text="Let's search your \nPlants! "
android:textColor="#color/toolbar_green"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.6"
app:layout_constraintHorizontal_bias="0.2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.9">
</TextView>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.Toolbar
android:id="#+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/transparent"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
<androidx.appcompat.widget.SearchView
android:id="#+id/searchbarplace"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="20dp"
android:background="#drawable/edit_txt_bg"
android:backgroundTint="#color/geen"
android:textColor="#1D623A"
android:textSize="25dp"
app:iconifiedByDefault="false"
app:queryHint="Search plants"
app:searchIcon="#drawable/ic_search">
</androidx.appcompat.widget.SearchView>
</com.google.android.material.appbar.AppBarLayout>
<!--Here is the problem for scrolling it under the appbar layout even adding all the flags-->
<androidx.core.widget.NestedScrollView
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintTop_toBottomOf="#+id/appbar">
<RelativeLayout
android:id="#+id/relativewrapped"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/appbar">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cards"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="false"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#color/white"
android:nestedScrollingEnabled="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</androidx.recyclerview.widget.RecyclerView>
<TextView
android:id="#+id/shp_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/cards"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="start|center"
android:text="Shop by category"
android:textColor="#color/toolbar_green"
android:textSize="22sp"
android:textStyle="bold|normal">
</TextView>
<LinearLayout
android:id="#+id/categ"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/shp_txt"
android:layout_marginStart="10dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal"
android:weightSum="4">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="3dp"
android:layout_weight="1"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="10dp"
app:cardCornerRadius="8dp">
<ImageButton
android:layout_width="87dp"
android:layout_height="87dp"
android:adjustViewBounds="true"
android:background="#drawable/edit_txt_bg"
android:baselineAlignBottom="false"
android:hapticFeedbackEnabled="true"
android:scaleType="centerInside"
android:src="#drawable/dragon_fin"></ImageButton>
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:text="Exotic Fruits"
android:textColor="#color/color_black"
android:textSize="15sp"></TextView>
</LinearLayout>
<TextView
android:id="#+id/offers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/categ"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:gravity="start|center"
android:text="Offers"
android:textColor="#color/toolbar_green"
android:textSize="22sp"
android:textStyle="bold|normal">
</TextView>
<HorizontalScrollView
android:id="#+id/newoffers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/offers"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:scrollbars="none">
<LinearLayout
android:id="#+id/truelinear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginRight="5dp"
android:orientation="horizontal" />
</HorizontalScrollView>
<View
android:id="#+id/gap1"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_below="#+id/newoffers"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"
android:background="#color/greyforgap">
</View>
<include
android:id="#+id/fruithori"
layout="#layout/fruits_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/gap1"
android:layout_marginLeft="5dp"
android:nestedScrollingEnabled="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Related
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>
I'm adding a BottomNavigationView to My MainActivity
at first show nothing wrong but after click on other items, BottomNavigationView strangely moving up and down. In other projects, I had never this problem and I don't know why I am getting this:
p.s: In default fragment (which is first at right in screenshot) I have a content but in other fragments, I have no content.
Here is my MainActivity layout:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.activity.MainActivity">
<FrameLayout
android:id="#+id/MainActivity_FrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/MainActivity_BottomView" />
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/colorPrimary"
app:menu="#menu/main_bottom_view_menu"
app:elevation="2dp"
app:itemTextColor="#android:color/white"
app:itemIconTint="#android:color/white"
android:id="#+id/MainActivity_BottomView"/>
</RelativeLayout>
and here is the screenshot of how does shown
after clicking on another item
and when select default item again
--- EDIT ---
I realized it's happen when use CoordinatorLayout , AppBarLayout and CollapsingToolbarLayout in fragment . After remove that lines app work without any problem .
Here is my fragment Layout :
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e2e2e2"
android:animateLayoutChanges="true"
android:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.fragment.MainFragments.ProfileFragment">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:background="#color/colorPrimaryDark"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimaryDark"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:titleEnabled="false"
app:scrimAnimationDuration="300"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:background="#color/colorPrimaryDark"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="140dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:id="#+id/Profile_InfoContainer"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content">
<com.graymind.applog.customview.CircleImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="#+id/Profile_ProfilePhoto"
android:layout_marginTop="10dp"
android:scaleType="centerCrop"
app:srcCompat="#drawable/login_bg"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:textColor="#android:color/white"
android:gravity="center"
android:id="#+id/Profile_FullName"
android:text="FullName"
android:textStyle="bold"/>
<TextView
android:id="#+id/Profile_Id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="'#gray_mind75"
android:textColor="#android:color/white"
android:textStyle="normal" />
</LinearLayout>
<TextView
android:id="#+id/Profile_Bio"
android:layout_width="match_parent"
android:layout_below="#+id/Profile_InfoContainer"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_marginBottom="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textSize="12sp"
android:lineSpacingExtra="4sp"/>
android:textColor="#android:color/white"
android:textDirection="rtl" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:weightSum="3"
android:layout_below="#+id/Profile_Bio"
android:layout_height="50dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:weightSum="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="1234"
android:textColor="#android:color/white"
android:textSize="#dimen/profile_stats_texts_size"
android:gravity="center"
tools:ignore="NestedWeights" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textSize="#dimen/profile_stats_texts_size"
android:textColor="#android:color/white"
android:gravity="center"
android:text="#string/post"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/colorPrimary"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:weightSum="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="1234"
android:textSize="#dimen/profile_stats_texts_size"
android:textColor="#android:color/white"
android:gravity="center"
tools:ignore="NestedWeights" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textColor="#android:color/white"
android:textSize="#dimen/profile_stats_texts_size"
android:gravity="center"
android:text="#string/followings"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/colorPrimary"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:weightSum="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="1234"
android:textSize="#dimen/profile_stats_texts_size"
android:textColor="#android:color/white"
android:gravity="center"
tools:ignore="NestedWeights" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textSize="#dimen/profile_stats_texts_size"
android:textColor="#android:color/white"
android:gravity="center"
android:text="#string/followers"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
app:layout_collapseMode="pin"
android:layout_height="?attr/actionBarSize">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/profile"
android:gravity="center"
android:layout_toStartOf="#+id/Profile_ToolbarProfileIcon"
android:textColor="#android:color/white"
android:layout_marginEnd="10dp"/>
<ImageView
android:layout_width="30dp"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:id="#+id/Profile_ToolbarProfileIcon"
android:layout_height="match_parent"
app:srcCompat="#drawable/ic_profile"
android:tint="#android:color/white"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:id="#+id/ProfilePostsScrollView"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:requiresFadingEdge="none"
android:id="#+id/Profile_PostsRecycler"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Thanks in advance for your guidance.
Change your root layout to LinearLayout like below:
<?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="match_parent"
android:orientation="vertical"
tools:context="com.activity.MainActivity">
<FrameLayout
android:id="#+id/MainActivity_FrameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
app:menu="#menu/main_bottom_view_menu"
app:elevation="2dp"
app:itemTextColor="#android:color/white"
app:itemIconTint="#android:color/white"
android:id="#+id/MainActivity_BottomView" />
</LinearLayout>
In my online food ordering app,in food detail section the image is not in right position.I am importing it from firebase database.
This is my fooddetail.java code
<?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"
tools:context="com.example.admin.clicknorder.FoodDetail"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
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/collapsing"
android:layout_width="match_parent"
android:layout_height="350dp"
app:layout_scrollFlags="exitUntilCollapsed"
app:contentScrim="#0d0e0d"
app:expandedTitleTextAppearance="#android:color/transparent"
>
</android.support.design.widget.CollapsingToolbarLayout>
<ImageView
android:id="#+id/image_food"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#null"
app:layout_collapseMode="parallax"
android:scaleType="fitXY"
/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:title="Food Name"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="parallax"
/>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/btnCart"
app:srcCompat="#drawable/ic_shopping_cart_black_24dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom|right|end"
app:useCompatPadding="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.v4.widget.NestedScrollView
android:id="#+id/nesterScrollView"
android:clipToPadding="false"
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="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="5dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/food_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:padding="12dp"
android:text="Food Name"
android:textColor="#color/colorPrimary"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:orientation="horizontal"
android:id="#+id/layout_price"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
app:srcCompat="#drawable/ic_attach_money_black_24dp"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/food_price"
android:layout_weight="9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="1,000"
android:textColor="#color/colorPrimary"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<com.cepheuen.elegantnumberbutton.view.ElegantNumberButton
android:layout_width="100dp"
android:layout_height="30dp"
android:id="#+id/number_button"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginBottom="18dp"
app:textSize="8sp"
app:backGroundColor="#color/colorAccent"
app:initialNumber="1"
app:finalNumber="20"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
app:cardElevation="5dp"
app:cardUseCompatPadding="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/food_description"
android:layout_marginTop="12dp"
android:lineSpacingMultiplier="1.5"
android:padding="12dp"
android:text="description"
android:textColor="#android:color/black"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
I don't know what is happening but if it is anything related to image resolution and size,please tell how can i fix it from android studio itself.
If any more details will require...i will edit my question.
Thank you
You have just placed your ImageView and Toolbar in wrong place
Move your image_food ImageView and Toolbar inside CollapsingToolbarLayout
Change your layout like below code
<?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">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title=""
app:titleEnabled="false">
<ImageView
android:id="#+id/image_food"
android:layout_width="match_parent"
android:layout_height="256dp"
android:contentDescription="#null"
android:scaleType="fitXY"
android:src="#drawable/kid_goku"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/btnCart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:elevation="6dp"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom|right|end"
app:pressedTranslationZ="12dp"
app:srcCompat="#drawable/ic_message"
app:useCompatPadding="true" />
<android.support.v4.widget.NestedScrollView
android:id="#+id/nesterScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="5dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/food_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:padding="12dp"
android:text="Food Name"
android:textColor="#color/colorPrimary"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/layout_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#drawable/ic_search" />
<TextView
android:id="#+id/food_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="9"
android:text="1,000"
android:textColor="#color/colorPrimary"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<com.cepheuen.elegantnumberbutton.view.ElegantNumberButton
android:id="#+id/number_button"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_marginBottom="18dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
app:backGroundColor="#color/colorAccent"
app:finalNumber="20"
app:initialNumber="1"
app:textSize="8sp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="5dp"
app:cardUseCompatPadding="true">
<TextView
android:id="#+id/food_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:lineSpacingMultiplier="1.5"
android:padding="12dp"
android:text="description"
android:textColor="#android:color/black"
android:textSize="14sp" />
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
RESULT
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"/>
Nested ScrollView has fragments which have RecyclerView and AppbarLayout does not scroll when dragged.
I have even added app:layout_behavior="#string/appbar_scrolling_view_behavior" in my RecyclerView as suggested in some answer but that does not work.
<android.support.design.widget.CoordinatorLayout
android:id="#+id/profile_view_cl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/color_control_highlight"
android:fitsSystemWindows="true"
android:focusableInTouchMode="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_8dp"
app:layout_behavior="com.practo.docnet.widgets.FlingBehavior"
android:theme="#style/Theme.AppCompat.NoActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="#color/color_primary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/color_white"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.5">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:layout_marginBottom="#dimen/profile_pic_margin_bottom"
android:layout_marginTop="#dimen/profile_pic_margin_top"
android:background="#android:color/white"
android:elevation="#dimen/card_padding"
android:gravity="center_horizontal|top"
app:cardCornerRadius="#dimen/default_elevation"
app:cardUseCompatPadding="false">
<ImageView
android:id="#+id/profile_pic_iv"
android:layout_width="#dimen/profile_pic_size"
android:layout_height="#dimen/profile_pic_size"
android:layout_gravity="center_horizontal"
android:layout_margin="#dimen/profile_pic_margin"
android:adjustViewBounds="true"
android:scaleType="fitXY"
/>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:orientation="vertical">
<ImageView
android:id="#+id/cover_pic"
android:layout_width="match_parent"
android:layout_height="#dimen/cover_pic_height"
android:layout_gravity="top"
android:fitsSystemWindows="true"
android:scaleType="fitXY"
android:src="#drawable/profile_placeholder"
android:tint="#color/cover_pic_tint" />
<LinearLayout
android:id="#+id/layout_titles"
android:layout_width="wrap_content"
android:layout_height="#dimen/titles_layout_height"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/titles_layout_margin_top"
android:orientation="vertical">
<TextView
android:id="#+id/first_name_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="sans-serif"
android:gravity="bottom|center"
android:textColor="#color/color_black"
android:textSize="#dimen/text_sz_xxxlarge" />
<TextView
android:id="#+id/designation_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/designation_text_margin_top"
android:fontFamily="sans-serif-light"
android:textColor="#color/color_black"
android:textSize="#dimen/text_sz_xlarge" />
<TextView
android:id="#+id/location_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/location_text_margin_top"
android:fontFamily="sans-serif-light"
android:textColor="#color/color_black"
android:textSize="#dimen/text_sz_xlarge" />
<TextView
android:id="#+id/no_of_connections_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/card_padding_more"
android:background="?selectableItemBackground"
android:fontFamily="sans-serif-medium"
android:textColor="#color/color_primary"
android:textSize="#dimen/text_sz_xxlarge" />
<TextView
android:id="#+id/connections_text_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/connections_text_margin_top"
android:background="?selectableItemBackground"
android:fontFamily="sans-serif-light"
android:text="#string/connections"
android:textColor="#color/color_black"
android:textSize="#dimen/text_sz_xlarge" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="center_horizontal"
app:layout_collapseMode="pin"
app:navigationIcon="#drawable/back_icon"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<TextView
android:id="#+id/title_textview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/margin_8dp"
android:gravity="center_vertical"
android:textColor="#android:color/white"
android:textSize="#dimen/text_sz_xxlarge" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="fill_vertical"
android:layout_marginTop="#dimen/margin_8dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="#+id/cards_layout_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:focusableInTouchMode="true"
android:orientation="vertical">
<include layout="#layout/profile_connect_layout" />