I am implementing native express ads in my app and I have a problem with setting the ad's width. While the height is pretty much straight forward, the width gives me trouble:
I've tried setting it like this:
adView.setAdSize(new AdSize((int) (getResources().getConfiguration().screenWidthDp - (getResources().getDimension(R.dimen.margin) / getResources().getDisplayMetrics().density)), 80));
AdSize takes dp parameters and you're converting the margins to pixels.
Also be aware of any padding that some views such as the AppCompat views add on some platforms and not others. For example
CardView adds 2dp padding on each side for KitKat and below, but there is no padding added for Lollipop and above.