I am using Appodeal.show(getActivity(),Appodeal.BANNER_BOTTOM); to position banner ad at the bottom of screen , but i want to keep some space between the ad and the bottom of the screen around 20dp because there is a share button which gets covered by the ad. So , how to position the bottom banner ad leaving some space below using java.
Asked
Active
Viewed 385 times
0
-
have you tried using margin to the adview ? – Hoque MD Zahidul Jan 13 '18 at 18:47
-
Actually i didn't write any code in xml for displaying the ad. I want to change the ad position using java code only, is it possible? – Girish Jan 13 '18 at 19:00
-
are you using admob ? – Hoque MD Zahidul Jan 13 '18 at 19:08
-
are you there ? – Hoque MD Zahidul Jan 13 '18 at 19:13
-
nope..i am using appodeal – Girish Jan 13 '18 at 19:41
1 Answers
0
You can add the desired margins using something like this. Just call this method whenever you are creating the adview
.
private void setBottomMargins (AdView adView, int bottomMargin) {
if (adView.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) adView.getLayoutParams();
layoutParams.setMargins(0, 0, 0, bottomMargin);
adView.requestLayout();
}
}