简体   繁体   中英

Android Snackbar showing white background behind text

I am using android design support library Snackbar using following code.

    Snackbar.make(rootView, "Sample Snackbar", Snackbar.LENGTH_LONG)
            .setAction("OK", view -> {})
            .setDuration(Snackbar.LENGTH_INDEFINITE)
            .show();

On Android 4.4 I am getting it like this:

在此处输入图片说明

I am not sure what am I doing wrong here.

EDIT

.setAction("OK", view -> {}) contains a lambda expression in the 2nd parameter. its just a empty listener.

I just had the same problem using FrameLayout as root view on a real device (android 6.0) when showing the snackbar inside a dialog. After changing it to

android.support.design.widget.CoordinatorLayout

the problem went away and the snackbar is showing correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM