Created
February 11, 2016 10:37
-
-
Save arturaz/7f555be24b39fe1b83f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
bannerFrame.addView(banner, new FrameLayout.LayoutParams( | |
finalWidth, finalHeight, | |
(isTopBanner ? Gravity.TOP : Gravity.BOTTOM) | Gravity.CENTER_HORIZONTAL | |
)); | |
ViewGroup root = (ViewGroup) activity.getWindow().getDecorView(); | |
root.addView(bannerFrame, new ViewGroup.LayoutParams( | |
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT | |
)); | |
Log.d(TAG, "Banner added to UI."); | |
setVisibilityUI(false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment