3

WHAT I HAVE

I am using Snackbar from the Design Support library in my app. I used to target API level 23 in my app, but have started noticing a weird problem after I started targeting API level 24.

THE PROBLEM

The problem only occurs for pre-lollipop devices, like Kitkat and Jellybean. It is perfectly fine for Lollipop and above devices. The height of the SnackBar is way too large compared to its standard size (please check the screenshot below).

When I using Design Support library and targeting API 23

compile 'com.android.support:design:23.4.0'

everything was working fine. But when I started targeting API 24 and using,

compile 'com.android.support:design:24.2.1'

the problem started occurring.

Is anyone else having the same issue? Is there something wrong I may be doing? How can it be fixed without decreasing the target SDK?

enter image description here

Aritra Roy
  • 15,355
  • 10
  • 73
  • 107

1 Answers1

2

This can be fixed by

Snackbar snackbar = Snackbar.make(getRoot(), text, duration);
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
    snackbar.getView().setFitsSystemWindows(false);
}
snackbar.show();
Daniel Puiu
  • 962
  • 6
  • 21
  • 29
lee
  • 21
  • 2