Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 58 additions & 42 deletions app/src/main/res/layout/ad_bottom_app_bar.xml
Original file line number Diff line number Diff line change
@@ -1,65 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.ads.nativead.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/ad_host"
<com.google.android.material.card.MaterialCardView
android:id="@+id/ad_card"
style="@style/Widget.Material3.CardView.Outlined"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurfaceContainer"
android:orientation="vertical"
android:paddingHorizontal="16dp">

<include
layout="@layout/ad_attribution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" />
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewTopRounded">

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
android:orientation="vertical"
android:padding="16dp">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ad_app_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginEnd="12dp" />
<include layout="@layout/ad_attribution" />

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
android:layout_marginTop="8dp"
android:gravity="center_vertical"
android:orientation="horizontal">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/ad_headline"
android:layout_width="wrap_content"
<FrameLayout
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="12dp">

<com.google.android.gms.ads.nativead.MediaView
android:id="@+id/ad_media"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ad_app_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
Comment on lines +29 to +43

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Hide icon when media asset is available

The new layout stacks MediaView and ad_app_icon in the same FrameLayout. NativeAdLoader.populateNativeAdView makes the icon view visible whenever nativeAd.getIcon() is present, without checking whether nativeAd.getMediaContent() is also provided. For ads that deliver both assets (which is the common case), the icon remains visible and sits on top of the MediaView, so the media content never becomes visible despite being loaded. This regresses the intent of switching to MediaView for the bottom bar ad. Consider hiding the icon when media content is present or showing the icon only when media is absent.

Useful? React with 👍 / 👎.

</FrameLayout>

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium" />
android:layout_weight="1"
android:orientation="vertical">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/ad_body"
<com.google.android.material.textview.MaterialTextView
android:id="@+id/ad_headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/ad_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.Material3.BodySmall" />
</androidx.appcompat.widget.LinearLayoutCompat>

<com.google.android.material.button.MaterialButton
android:id="@+id/ad_call_to_action"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.Material3.BodySmall" />
android:layout_marginStart="8dp"
android:minWidth="88dp"
android:minHeight="40dp" />
</androidx.appcompat.widget.LinearLayoutCompat>

<com.google.android.material.button.MaterialButton
android:id="@+id/ad_call_to_action"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:minWidth="88dp"
android:minHeight="40dp" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.google.android.material.card.MaterialCardView>
</com.google.android.gms.ads.nativead.NativeAdView>