I got an email from AdMob today saying:
Change to native ads policy: Native ads will require MediaView to render the video or main image asset. In a
To ensure that all media are as wide as possible and that they respect a maximum height (so there are no surprises depending on the dimensions of the media).
XML
JAVA
mediaView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
@Override
public void onChildViewAdded(View parent, View child) {
float scale = context.getResources().getDisplayMetrics().density;
int maxHeightPixels = 175;
int maxHeightDp = (int) (maxHeightPixels * scale + 0.5f);
if (child instanceof ImageView) { //Images
ImageView imageView = (ImageView) child;
imageView.setAdjustViewBounds(true);
imageView.setMaxHeight(maxHeightDp);
} else { //Videos
ViewGroup.LayoutParams params = child.getLayoutParams();
params.height = maxHeightDp;
child.setLayoutParams(params);
}
}
@Override
public void onChildViewRemoved(View parent, View child) {}
});