Trying to show snackBar in the snippet. Here is the markup:
<?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" android:id="@+id/received" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <View android:id="@+id/view_1" android:layout_width="match_parent" android:layout_height="2dp" android:layout_marginTop="3dp" android:background="@color/colorAccent" /> <android.support.design.widget.BottomNavigationView android:id="@+id/bottom_navigation_ms" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_marginTop="5dp" android:textAlignment="gravity" android:theme="@style/Widget.BottomNavigationView" app:itemBackground="@color/bottom_color_2" app:itemIconTint="@drawable/selected_text_2" app:itemTextColor="@drawable/selected_text_2" app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior" app:menu="@menu/message_center_menu" /> <View android:layout_width="match_parent" android:layout_height="5dp" android:id="@+id/view_2" android:layout_marginTop="57dp" android:background="@color/test_color" /> <TextView android:id="@+id/emptyList" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="75dp" android:gravity="center_horizontal" android:text="@string/no_messages" android:textSize="32sp" android:textStyle="italic" android:visibility="gone" /> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/refresh_2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginStart="5dp" android:background="@color/white" android:layout_marginTop="66dp" android:layout_marginEnd="5dp" android:layout_marginBottom="10dp"> <android.support.v7.widget.RecyclerView android:id="@+id/list_res" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" /> </android.support.v4.widget.SwipeRefreshLayout> </RelativeLayout>
At first I did this:
Snackbar snackbar = Snackbar.make(relativeLayout, "Item was removed from the list.", Snackbar.LENGTH_LONG); snackbar.setAction("UNDO", new View.OnClickListener() { @Override public void onClick(View view) { adapter.restoreItem(item, viewHolder.getAdapterPosition()); recyclerView.scrollToPosition(viewHolder.getAdapterPosition()); } }); snackbar.setActionTextColor(Color.YELLOW); snackbar.show();
the bar did not appear, then decided that the root element was probably incorrectly assigned to where I am trying to show, so I connected the main relativeLayout, but I still don’t see anything. Played with margins, but still I see nothing. On the Internet, they mostly write that the problem is that the root element was selected incorrectly, but I tried everything for everyone and nothing helped. Maybe someone knows what could be the problem?