I have activity_home_page.xml
which has a FrameLayout
and bottomNavigationView
.
activity_home_page.xml
<?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=".activity.HomePage">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/rootlayout_homepage_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container_Homepage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/nv_Homepage"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_gravity="bottom"
android:background="@color/white"
android:foregroundGravity="fill"
app:elevation="8dp"
app:itemIconSize="20dp"
app:itemIconTint="@color/bottom_nav_custom"
app:itemTextColor="@color/bottom_nav_custom"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_insetEdge="bottom"
app:menu="@menu/homepage_navigation_menu" />
</android.support.design.widget.CoordinatorLayout>
The bottomNavigationBar
has multiple tabs. On click of the tabs, I am inflating one of fragments
in FrameLayout
of id container_Homepage in above shown activity. One of the fragment is as below:
fragment_homepage_home.xml
<?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/rootlayout_homepage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="56dp"
tools:context=".activity.HomePage">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_gravity="bottom|end"
android:layout_marginBottom="16dp"
android:layout_marginRight="@dimen/fab_margin"
app:backgroundTint="#FF31ACF2"
app:elevation="10dp"
app:fabSize="normal"
app:srcCompat="@drawable/ic_call" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:scrollbars="vertical" />
<RelativeLayout
android:id="@+id/loadingView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#000000"
android:visibility="gone">
<ProgressBar
android:id="@+id/pbLoading"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:visibility="gone" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
I have made common method for showing snackbar
where pass view and message.the method is as follows:
public static void showSnack(String msg, View view) {
final Snackbar snackbar = Snackbar.make(view, msg, Snackbar.LENGTH_LONG);
View sbView = snackbar.getView();
TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.WHITE);
snackbar.setAction("Dismiss", new View.OnClickListener() {
@Override
public void onClick(View v) {
snackbar.dismiss();
}
});
snackbar.setActionTextColor(Color.WHITE);
snackbar.show();
}
I tried implementing this but still getting the same. I wish to show snackbar
above bottomNavigationView
but I am getting
"java.lang.IllegalArgumentException: No suitable parent found from the given view. Please provide a valid view."
error when I pass rootlayout_homepage
from fragment_homepage_home
as parent view.
Which view should I provide to snackbar for getting snackbar
above the bottomNavigationView
?
Unable to figure out where I am going wrong.