I have a Snackbar
which is as follows:
However, if the drop down of the AutoCompleteTextView
is too long, the drop down will block the Snackbar
.
As you can see in the above image, the Snackbar
is actually showing. However, its visibility is blocked by the long drop down. You can see from the above image
I try to use the following Snackbar code
. Adding bringToFront()
doesn't help much.
private void showSnackbar(String message) {
Snackbar snackbar
= Snackbar.make(getActivity().findViewById(R.id.content), message, Snackbar.LENGTH_LONG);
snackbar.getView().bringToFront();
snackbar.show();
}
R.id.content
is a CoordinatorLayout
:
<android.support.design.widget.CoordinatorLayout
android:id="@+id/content"
android:background="?attr/MyActivityBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="?attr/headerShadow" />
Is there any good way, to avoid Snackbar
from being covered by AutoCompleteTextView
's drop down?
ListPopupWindow
material style has elevation of16dp
, so if you setSnackbar
elevation to be bigger by callingsnackbar.getView().setElevation([float])
, that might work. But will work only for Lollipop+. – Whipsaw