My current Android application employs
com.google.android.material.bottomnavigation.BottomNavigationView
with app:layout_behavior="#string/hide_bottom_view_on_scroll_behavior"
The view content is a androidx.recyclerview.widget.RecyclerView
I have an issue when the number of items displayed in the list is insufficient to enable scrolling.
I this case the BottomNavigationView does not hide and so the last item in the list is partially hidden.
I resolved this issue by adding a bottom margin to my RecyclerView of android:layout_marginBottom="?attr/actionBarSize"
This fix now causes an issue when my BottomNavigationView is hiding due to scroll and the user
has scrolled to the last item in the list.
The user sees a blank bar at the bottom of the screen due to the bottom margin.
Is there any way I can fix both cases?
My main xml resembles this
<?xml version="1.0" encoding="utf-8"?>
<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/suggest_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/toolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
style="#style/Widget.MaterialComponents.Toolbar.Primary"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">
<View
android:id="#+id/paddingView"
style="?android:attr/progressBarStyle"
android:layout_width="#dimen/size_menu_progressbar"
android:layout_height="#dimen/size_menu_progressbar"
android:layout_gravity="end" />
<ProgressBar
android:id="#+id/myProgressBar"
style="?android:attr/progressBarStyle"
android:layout_width="#dimen/size_menu_progressbar"
android:layout_height="#dimen/size_menu_progressbar"
android:layout_gravity="end"
android:visibility="invisible" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/main_area"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.fragment.app.FragmentContainerView
android:id="#+id/navHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
android:layout_marginBottom="?attr/actionBarSize"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="#navigation/my_graph"
tools:context=".MyActivity" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/home_bottom_navigation_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:itemIconTint="#color/bottom_navigation_bar_color"
app:itemTextColor="#color/bottom_navigation_bar_color"
app:labelVisibilityMode="unlabeled"
app:layout_behavior="#string/hide_bottom_view_on_scroll_behavior"
app:menu="#menu/bottom_nav_menu" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
My content layout resembles this
<?xml version="1.0" encoding="utf-8"?><!-- Use DrawerLayout as root container for activity -->
<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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="#dimen/margin5"
tools:context=".MyFragment">
<androidx.appcompat.widget.SearchView
android:id="#+id/search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true" />
<ViewFlipper
android:id="#+id/recyclerViewFlipper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/margin6">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_search" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3">
<TextView
android:id="#+id/find_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/margin4"
android:textColor="#color/dark_grey"
android:textSize="#dimen/text4"
android:textStyle="bold" />
<TextView
android:id="#+id/find_title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/find_title"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/margin4"
android:gravity="center_horizontal"
android:textColor="#color/dark_grey"
android:textSize="#dimen/text3"
android:textStyle="normal" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="#layout/pager_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:listitem="#layout/item_my_item" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<ImageView
android:id="#+id/image"
android:layout_width="90dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_no_found" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/margin6"
android:textColor="#color/dark_grey"
android:textSize="#dimen/text4"
android:textStyle="bold" />
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/margin3"
android:textColor="#color/dark_grey"
android:textSize="#dimen/text4" />
</LinearLayout>
</RelativeLayout>
</ViewFlipper>
</LinearLayout>
</layout>
You can use android:paddingBottomand android:clipToPadding.
Just set android:paddingBottom to the BottomNavigation height and android:clipToPadding tp false
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="8dp"
android:paddingBottom="?attr/actionBarSize"
app:layout_behavior="#string/hide_bottom_view_on_scroll_behavior"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="#layout/item_layout" />
try this-->
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
private boolean hasFixedLastItemNotVisible = false;
#Override
public void onScrollStateChanged(#NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (!hasFixedLastItemNotVisible &&
!recyclerView.canScrollVertically(10) &&
newState==RecyclerView.SCROLL_STATE_IDLE) {
hasFixedLastItemNotVisible = true;
recyclerView.getAdapter().notifyDataSetChanged();
}
}
});
Related
I have a BottomNavigationView Bar on my App. This bar does not show on where it is placed until it's scrolled.
How can I change the Behavior so that the bar shows even without scrolling. That is I want a permanent Fixed position to the bottom, if user does not scroll id remains there, if they scroll it remains there still.
Here is my app_bar xml code
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.sckoolboy.app.AspirantOfflineActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:visibility="gone"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/content_main" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:fitsSystemWindows="true"
android:background="?android:attr/windowBackground"
android:foreground="?attr/selectableItemBackground"
app:menu="#menu/master_bottom_navigation"
app:elevation="10dp"
app:labelVisibilityMode="labeled"
app:itemIconTint="#color/accent"
app:itemTextColor="#color/black"
app:itemBackground="#color/bottomNavigationBackground"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
And below is how this bar appears on my main activity
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context="com.sckoolboy.app.AspirantOfflineActivity"
tools:showIn="#layout/app_bar_main"
style="#style/parent.contentLayout">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/textViewUser"
style="#style/viewParent.headerText"
android:maxLines="2"
android:text="Aspirant Mode"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"/>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profileCircleImageView"
android:layout_width="60dp"
android:layout_height="60dp"
app:civ_border_width="2dp"
app:civ_border_color="#color/colorAccent"
android:src="#drawable/icon"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
app:cardCornerRadius="16dp"
app:cardPreventCornerOverlap="false"
app:cardBackgroundColor="#color/colorAccent"
android:minHeight="200dp"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome to \nSckoolboy"
android:textColor="#color/whiteBodyColor"
android:textStyle="bold"
android:textSize="20sp"/>
<TextView
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20% Complete"
android:textColor="#color/whiteBodyColor"
android:textStyle="bold"
android:textSize="13sp"/>
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:src="#drawable/hero"
android:elevation="44dp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:text="Popular"
style="#style/viewParent.headerText"/>
<TextView
android:layout_alignParentRight="true"
style="#style/viewParent"
android:text="See All"
android:layout_centerVertical="true"
android:textSize="#dimen/headerMoreTextSize"
android:textColor="#color/colorAccent"
android:textStyle="bold"/>
</RelativeLayout>
<!--remove the below layout with recycler view, use card poplar courses as model for design-->
<LinearLayout
android:layout_width="match_parent"
android:layout_marginBottom="50dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="#+id/includeCallEnd0"
layout="#layout/offline_exam_etest"/>
<include
android:id="#+id/includeCallEnd0"
layout="#layout/sckoolboy_community"/>
<include
android:id="#+id/includeCallEnd0"
layout="#layout/sckoolboy_radio"/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
You can get the BottomNavigationView out of the CoordinatorLayout, and add both to another root layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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.sckoolboy.app.AspirantOfflineActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/navigation">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:visibility="gone"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/content_main" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:fitsSystemWindows="true"
android:background="?android:attr/windowBackground"
android:foreground="?attr/selectableItemBackground"
app:menu="#menu/master_bottom_navigation"
app:elevation="10dp"
app:labelVisibilityMode="labeled"
app:itemIconTint="#color/accent"
app:itemTextColor="#color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:itemBackground="#color/bottomNavigationBackground"/>
</androidx.constraintlayout.widget.ConstraintLayout>
I was trying to have a map displayed on one of the fragments of the Bottom Navigation.
But, attached fragment is not covering complete screen. i tried adding background color to the fragment is as below:
While trying to add a map to the fragment it also is not convering the complete screen instead it shows only a bit of the screen.
Below my layout code:
Bottom Navigation.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_5">
<include
android:id="#+id/search_bar"
layout="#layout/include_card_view_search_bar" />
<androidx.core.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="#dimen/spacing_middle" />
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/blue_500"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#color/blue_grey_700"
app:itemIconTint="#drawable/color_state_white_2"
app:itemTextColor="#drawable/color_state_white_2"
app:menu="#menu/menu_bottom_navigation_shifting" />
</RelativeLayout>
My Map Fragment:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#drawable/bg_gradient_soft" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#android:color/white"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:padding="#dimen/spacing_medium">
<ImageButton
android:id="#+id/map_button"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:onClick="clickAction"
android:tint="#color/colorPrimary"
app:srcCompat="#drawable/ic_near_me" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Map"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Subhead"
android:textColor="#color/colorPrimary"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="?attr/actionBarSize"
android:layout_height="0dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:padding="#dimen/spacing_medium">
<ImageButton
android:id="#+id/list_button"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:onClick="clickAction"
android:tint="#color/colorPrimary"
app:srcCompat="#drawable/ic_format_list_bulleted" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Subhead"
android:textColor="#color/colorPrimary"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/add_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginBottom="15dp"
android:clickable="true"
android:onClick="clickAction"
android:tint="#android:color/white"
app:backgroundTint="#color/colorPrimary"
app:elevation="2dp"
app:fabSize="normal"
app:rippleColor="#color/deep_orange_400"
app:srcCompat="#drawable/ic_add" />
</RelativeLayout>
Attaching the Map using my code:
mapFragment = (SupportMapFragment) this.getChildFragmentManager().findFragmentById(R.id.map);
The app looks like below:
add android:fillViewport="true" in NestedScrollView
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_5">
<include
android:id="#+id/search_bar"
layout="#layout/include_card_view_search_bar" />
<androidx.core.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="#dimen/spacing_middle" />
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/blue_500"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#color/blue_grey_700"
app:itemIconTint="#drawable/color_state_white_2"
app:itemTextColor="#drawable/color_state_white_2"
app:menu="#menu/menu_bottom_navigation_shifting" />
</RelativeLayout>
If NestedScrollView is not necessary try using some other ViewGroup i.e LinearLayout or RelativeLayout in its place. It seems the issue is in wrapping fragment content inside NestedScrollView.
You have taken FrameLayout(id-content) inside NestedScrollView, try removing NestedScrollView from there and adding it to the layout by which you are replacing it with FrameLayout(id-content)
this is similar to many questions but I got some different scenario . Let me explain scenario first , I have a MainActivity with BottomNavigationView & FrameLayout for switching Fragments according to BottomNavigation items click. One of the fragment has FAB & within this Fragment I need to display Snackbar .
What I have tried so far,
1) Added BottomNavigationView inside another FrameLayout , but SnackBar overlapping .
2) Added BottomBar into sub CoordinatorLayout & snackbar is behind Bottombar
Here are XMLs for MainActivity & Fragment
<?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=".activities.HomeActivity">
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:elevation="5dp"
android:background="#android:color/white"
app:itemBackground="#android:color/white"
android:foreground="?attr/selectableItemBackground"
app:labelVisibilityMode="labeled"
app:itemTextColor="#color/darkestGrey"
app:menu="#menu/navigation" />
</android.support.design.widget.CoordinatorLayout>
Here is Fragment layout:
<?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:id="#+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.PayloadsFragment">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<FrameLayout
android:id="#+id/toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/payloads_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:title="#string/overview"
app:titleTextColor="#color/white"
app:popupTheme="#style/AppTheme.PopupOverlay" />
<com.miguelcatalan.materialsearchview.MaterialSearchView
android:id="#+id/search_view"
android:hint="#string/hint_search_payload"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
<include layout="#layout/bottom_filter_sheet" />
</android.support.design.widget.CoordinatorLayout>
content_main.xml
<?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"
android:layout_marginBottom="51dp"
android:background="#color/white"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".activities.HomeActivity">
<TextView
android:id="#+id/txt_stick_status_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="#dimen/padd_10"
android:layout_marginTop="#dimen/padd_10"
android:fontFamily="sans-serif-medium"
android:maxLines="2"
android:text="#string/str_stick"
android:textColor="#color/item_name"
android:textSize="17sp" />
<TextView
android:id="#+id/txt_stick_status_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="5dp"
android:layout_marginTop="9dp"
android:layout_toEndOf="#id/txt_stick_status_title"
android:fontFamily="sans-serif-medium"
android:maxLines="2"
android:text="#string/str_stick_not_available"
android:textColor="#color/darkestGrey"
android:textSize="18sp" />
<ImageButton
android:id="#+id/btn_connect_stick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/title_margin"
android:layout_marginTop="9dp"
android:layout_toEndOf="#+id/txt_stick_status_value"
android:background="#null"
android:scaleType="centerCrop"
app:srcCompat="#drawable/ic_disconnected" />
<ImageButton
android:id="#+id/btn_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="8dp"
android:layout_marginEnd="#dimen/padd_10"
android:background="#drawable/bg_grey_rounded_border"
android:padding="6dp"
app:srcCompat="#drawable/ic_filter" />
<ImageView
android:id="#+id/img_filter_active"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentEnd="true"
android:padding="#dimen/small_5_margin"
android:src="#drawable/ic_active_filter"
android:visibility="gone" />
<RelativeLayout
android:id="#+id/layout_no_device_configure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_filter"
android:layout_marginTop="#dimen/row_padding_vertical"
android:background="#color/snackbar_bg"
android:elevation="3dp"
android:padding="#dimen/title_margin"
android:visibility="visible">
<TextView
android:id="#+id/lbl_no_device_configure"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:fontFamily="sans-serif-light"
android:text="#string/lbl_no_device_configure"
android:textColor="#color/white"
android:textSize="16sp" />
<TextView
android:id="#+id/lbl_buy_input_stick_website"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:layout_marginEnd="5dp"
android:ellipsize="end"
android:fontFamily="sans-serif-medium"
android:text="#string/lbl_tap_to_configure"
android:textAllCaps="true"
android:textColor="#color/colorAccent"
android:textSize="16sp" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/layout_no_device_configure">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/title_default_payloads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/padd_10"
android:text="#string/default_payloads_title"
android:textColor="#color/item_name"
android:textStyle="bold" />
<android.support.v7.widget.RecyclerView
android:id="#+id/payload_recycler_view_default_payloads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/small_5_margin"
android:scrollbars="vertical" />
<TextView
android:id="#+id/title_custom_payloads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:padding="#dimen/padd_10"
android:text="#string/custom_payloads_title"
android:textColor="#color/item_name"
android:textStyle="bold" />
<android.support.v7.widget.RecyclerView
android:id="#+id/payload_recycler_view_custom_payloads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</LinearLayout>
</ScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fb_add_payload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="#dimen/activity_horizontal_margin"
android:layout_marginEnd="#dimen/activity_horizontal_margin"
android:layout_marginBottom="10dp"
app:backgroundTint="#color/colorAccent"
app:fabSize="normal"
app:maxImageSize="17dp"
app:srcCompat="#drawable/ic_add" />
</RelativeLayout>
Do let me know if any other information is required .
Any help would be appreciated .
While displaying your snack bar programmatically, try this instead:
Snackbar snack = Snackbar.make(findViewById(R.id.coordinator_layout),
successMessage, Snackbar.LENGTH_INDEFINITE);
snack.setAction("Ok", v -> snack.dismiss());
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams)
snack.getView().getLayoutParams();
params.setAnchorId(R.id.navigation);
params.anchorGravity = Gravity.TOP;
params.gravity = Gravity.TOP;
snack.getView().setLayoutParams(params);
snack.show();
If you are calling a SnackBar from Fragment you may do something like this:
private fun showSnackBarMessage() {
val bottomNavView: BottomNavigationView = activity?.findViewById(R.id.bottom_nav)!!
Snackbar.make(bottomNavView, "No data available", Snackbar.LENGTH_SHORT).apply {
anchorView = bottomNavView
}.show()
}
You may obtain bottomNavView from the activity's layout and then use it as anchor view for SnackBar. Now it'll be displayed above Bottom Navigation Bar
I have a recyclerview populated with a list from an API. I am using RxBinding to search and filter the list. The current problem is with my layout. I would like my search bar field at the top with the list beneath it. Below is an example of my list being filtered but as you can see the searchbar text and the List Items overlap
Now below is the layout file.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<android.support.v7.widget.RecyclerView
android:id="#+id/listRecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/searchView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_weight="1"
android:background="#android:color/transparent"
android:inputType="text" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="end|center_vertical"
android:src="#android:drawable/ic_menu_search" />
</FrameLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
Eventually I want the searchbar to be scrollable as well, so that when the user scrolls down the list, the searchbar will be rotated out. However I think this will involve me created a list of some CommonInterface which my both my SearchBar and ListItems would have to implement.
Use RelativeLayout like this so that recyclerView is below the editText and add a scrollView so that the scrolling happens on the whole layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/listRecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edit"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edit">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/searchView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_weight="1"
android:background="#android:color/transparent"
android:inputType="text" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="end|center_vertical"
android:src="#android:drawable/ic_menu_search" />
</FrameLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
And add this in your RecyclerView in Java:
recyclerView.setNestedScrollingEnabled(false);
You can try this layout
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="#color/atehensGray"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/chrome_grey"
android:fitsSystemWindows="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<SearchView
android:id="#+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="#drawable/rounded_corners"
android:gravity="top"
android:hapticFeedbackEnabled="true"
android:orientation="horizontal"
android:visibility="visible"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="1.0" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#color/white"
android:id="#+id/recyclerView_main"
android:layout_width="0dp"
android:layout_height="0dp"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/appBarLayout" />
</android.support.constraint.ConstraintLayout>
I have searched alot but could not find any working method to achieve this, I have a simple fragment layout. here it is
<FrameLayout 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"
tools:context="ir.gfpishro.signal.FragMalls">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/relative_layout_error"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<include
layout="#layout/wifi_error_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycle_mall_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="gone">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
In this layout I have a recycleview and a relativelayout which includes another layout. it is named wifi_error_layout which I call it error__ layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/image_icon"
android:layout_width="108dp"
android:layout_height="108dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_no_connection_24dp_white"
tools:background="#000000"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/text_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:textColor="#color/colorAccent"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/image_icon"
tools:text="#string/progressActivityEmptyTitlePlaceholder" />
<TextView
android:id="#+id/text_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="56dp"
android:layout_marginRight="56dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:lineSpacingExtra="5.5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/text_title"
tools:text="#string/progressActivityEmptyContentPlaceholder" />
<Button
android:id="#+id/button_retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:text="#string/progressActivityErrorButton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
style="#style/ButtonOrange"
app:layout_constraintTop_toBottomOf="#+id/text_content" />
</android.support.constraint.ConstraintLayout>
I want them to overlap each other and each time I face an error while loading data into recycleview I make error__ layout visible. but It does not work. I use this function to make it visible and invisible
private void finishUpdate(Boolean status){
mSwipeRefreshLayout.setRefreshing(false);
if(status){
error__.setVisibility(View.INVISIBLE);
recyclerView.setVisibility(View.VISIBLE);
}else{
error__.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.INVISIBLE);
}
}
but I could not make it work. I tried to use setZ but it needs to change minbuildsdk and I do not want to do that. I know in Frame layout the order of views indicates the z index but why when I make error__ layout invisible it does not show recyleview. If I change the order of views in xml manually this will work on recycleview but the problem occurs on error__ layout. I mean when I hidden the top view it does not show its bottom view.
The below code is correct, you should put your include outside refresh layout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycle_mall_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</android.support.v4.widget.SwipeRefreshLayout>
<RelativeLayout
android:id="#+id/relative_layout_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible">
<include
layout="#layout/wifi_error_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</FrameLayout>
Update your following method :
private void finishUpdate(Boolean status){
mSwipeRefreshLayout.setRefreshing(false);
if(status){
error__.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE);
}else{
error__.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.GONE);
}
}
Also update fragment with following:
<FrameLayout 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"
tools:context="ir.gfpishro.signal.FragMalls">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/relative_layout_error"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<include
layout="#layout/wifi_error_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycle_mall_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="gone">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
Use your layout like this, also
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="ir.gfpishro.signal.FragMalls">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycle_mall_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="250dp"
android:visibility="gone">
<android.support.constraint.ConstraintLayout
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="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<ImageView
android:id="#+id/image_icon"
android:layout_width="108dp"
android:layout_height="108dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_no_connection_24dp_white"
tools:background="#000000"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/text_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:textColor="#color/colorAccent"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/image_icon"
tools:text="#string/progressActivityEmptyTitlePlaceholder" />
<TextView
android:id="#+id/text_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="56dp"
android:layout_marginRight="56dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:lineSpacingExtra="5.5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/text_title"
tools:text="#string/progressActivityEmptyContentPlaceholder" />
<Button
android:id="#+id/button_retry"
style="#style/ButtonOrange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:text="#string/progressActivityErrorButton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/text_content" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</RelativeLayout>
and also use View.Gone instead of View.Invisible.
private void finishUpdate(Boolean status){
mSwipeRefreshLayout.setRefreshing(false);
if(status){
error__.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE);
}else{
error__.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.GONE);
}
}