1

I'm targeting API 23.

Previously, I am using FrameLayout's setForeground method in device with API 16 without any issues.

Recently, I migrate FrameLayout to android.support.design.widget.CoordinatorLayout, with intention to continue support for device with API 16.

To my surprise, setForeground for View, is only available since API 23.

Also, bug in documentation will give you lotsa headache - Call requires API level 23: getForeground() error, but is a FrameLayout method since API 1

So, may I know how do you perform setForeground on android.support.design.widget.CoordinatorLayout, for device with API 16?

ViewCompat doesn't help much, as it doesn't contain setForeground method.

Ronak Thakkar
  • 2,515
  • 6
  • 31
  • 45
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
  • 3
    You could wrap the `CoordinatorLayout` in a `FrameLayout`, or subclass `CoordinatorLayout`, and handle drawing the foreground yourself after the `super` call in `dispatchDraw()`. – Mike M. Jun 05 '17 at 09:31

0 Answers0