Created
February 11, 2016 10:11
-
-
Save arturaz/aa2964b7518614822426 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); | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment