Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. void addToUI(int width, int height, boolean isTopBanner) {
  2. float density = activity.getResources().getDisplayMetrics().density;
  3. int finalWidth = (int)(width * density);
  4. int finalHeight = (int)(height * density);
  5.  
  6. bannerFrame = new FrameLayout(activity);
  7. RelativeLayout.LayoutParams bannerLayoutParams =
  8. new RelativeLayout.LayoutParams(finalWidth, finalHeight);
  9. bannerFrame.addView(banner, bannerLayoutParams);
  10.  
  11. ViewGroup root = (ViewGroup) activity.getWindow().getDecorView();
  12. root.addView(bannerFrame, new FrameLayout.LayoutParams(
  13. FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT,
  14. (isTopBanner ? Gravity.TOP : Gravity.BOTTOM) | Gravity.CENTER_HORIZONTAL
  15. ));
  16.  
  17. Log.d(TAG, "Banner added to UI.");
  18. setVisibilityUI(false);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement