private Rect getActionModeBounds() { if (mActivity instanceof IAppCompatActivity) { final Rect bounds = new Rect(); final int[] location = new int[2]; final ActionBar actionBar = ((IAppCompatActivity) mActivity).getSupportActionBar(); final Toolbar toolbar = AppCompatUtils.findToolbarForActionBar(actionBar); if (toolbar != null) { toolbar.getLocationInWindow(location); bounds.left = location[0]; bounds.top = location[1]; bounds.right = bounds.left + toolbar.getWidth(); bounds.bottom = bounds.top + toolbar.getHeight(); return bounds; } } return null; }