Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void addToUI(int width, int height, boolean isTopBanner) {
- float density = activity.getResources().getDisplayMetrics().density;
- int finalWidth = (int)(width * density);
- int finalHeight = (int)(height * density);
- bannerFrame = new FrameLayout(activity);
- RelativeLayout.LayoutParams bannerLayoutParams =
- new RelativeLayout.LayoutParams(finalWidth, finalHeight);
- bannerFrame.addView(banner, bannerLayoutParams);
- ViewGroup root = (ViewGroup) activity.getWindow().getDecorView();
- root.addView(bannerFrame, new FrameLayout.LayoutParams(
- FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT,
- (isTopBanner ? Gravity.TOP : Gravity.BOTTOM) | Gravity.CENTER_HORIZONTAL
- ));
- Log.d(TAG, "Banner added to UI.");
- setVisibilityUI(false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement