MediaView not respecting maxHeight

221 views
Skip to first unread message

Serhat

unread,
Apr 10, 2017, 10:28:56 AM4/10/17
to Google Mobile Ads SDK Developers
            <com.google.android.gms.ads.formats.MediaView
               
android:id="@+id/appinstall_media"
               
android:layout_width="match_parent"
               
android:layout_height="wrap_content"
               
android:maxHeight="200dp"
               
android:padding="2dp">


When ad does not contain video, image of the ad in the MediaView fills the entire screen. When there is a video ad, then MediaView wraps the content as it should.

Serhat

unread,
Apr 10, 2017, 11:02:51 AM4/10/17
to Google Mobile Ads SDK Developers
I had to set a OnHierarchyChangeListener to MediaView to be able to reach ImageView inside it. It is a shame devs have to use workaround like this.

MediaView m = adView.getMediaView();
m
.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
   
@Override
    public void onChildViewAdded(View parent, View child) {
       
if (child instanceof ImageView) {
           
ImageView imageView = (ImageView) child;
            imageView.setAdjustViewBounds(true);
       
}
   
}

   
@Override
    public void onChildViewRemoved(View parent, View child) {}
});
Reply all
Reply to author
Forward
0 new messages