Code example for PopupWindow

Methods: setBackgroundDrawableshowAsDropDown

0
      assertNotNull(shadowWindowManager.getViews().get(0).findViewById(R.id.content_view));
    } 
 
    @Test 
    public void backgroundDrawableIsBehindPopupViewContainer() throws Exception { 
      PopupWindow popupWindow = new PopupWindow(contentView);
      BitmapDrawable background = new BitmapDrawable();
      popupWindow.setBackgroundDrawable(background);
      popupWindow.showAsDropDown(anchor);
      assertSame(background, shadowWindowManager.getViews().get(0).getBackground());
    } 
 
    @Test 
    public void dismiss_removesContainerFromWindowManager() throws Exception { 
      PopupWindow popupWindow = new PopupWindow(contentView);
      popupWindow.showAsDropDown(anchor);
      popupWindow.dismiss();
      assertEquals(0, shadowWindowManager.getViews().size());
    } 
  } 
}