Skip to content

Commit 183dc29

Browse files
Refactor bottom app bar native ad layout
The layout for the bottom app bar native ad was refactored to: - Use a LinearLayout as the root container instead of MaterialCardView. - Adjust padding and margins for better visual appearance. - Set a minimum width and height for the ad call-to-action button. - Change the ad container height in `activity_main.xml` to `wrap_content`.
1 parent fa65261 commit 183dc29

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<FrameLayout
4545
android:id="@+id/ad_container"
4646
android:layout_width="match_parent"
47-
android:layout_height="50dp"
47+
android:layout_height="wrap_content"
4848
app:layout_constraintBottom_toTopOf="@+id/nav_view">
4949

5050
<View

app/src/main/res/layout/bottom_app_bar_native_ad.xml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<com.google.android.gms.ads.nativead.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
43
android:layout_width="match_parent"
54
android:layout_height="wrap_content">
65

7-
<com.google.android.material.card.MaterialCardView
8-
android:id="@+id/ad_card"
9-
style="@style/Widget.Material3.CardView.Outlined"
6+
<LinearLayout
7+
android:id="@+id/ad_host"
108
android:layout_width="match_parent"
119
android:layout_height="wrap_content"
12-
android:layout_marginHorizontal="16dp"
13-
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewTopRounded">
10+
android:orientation="vertical"
11+
android:background="?attr/colorSurfaceContainer"
12+
android:paddingStart="16dp"
13+
android:paddingEnd="16dp"
14+
android:paddingTop="12dp"
15+
android:paddingBottom="12dp">
1416

15-
<include
16-
layout="@layout/ad_attribution"
17-
android:layout_gravity="top|start"
18-
android:layout_margin="8dp" />
17+
<include layout="@layout/ad_attribution" />
1918

2019
<LinearLayout
2120
android:layout_width="match_parent"
2221
android:layout_height="wrap_content"
23-
android:orientation="horizontal"
2422
android:gravity="center_vertical"
25-
android:paddingStart="16dp"
26-
android:paddingEnd="16dp"
27-
android:paddingTop="24dp"
28-
android:paddingBottom="8dp">
23+
android:orientation="horizontal">
2924

3025
<ImageView
3126
android:id="@+id/ad_app_icon"
@@ -61,7 +56,9 @@
6156
style="@style/Widget.Material3.Button.TextButton"
6257
android:layout_width="wrap_content"
6358
android:layout_height="wrap_content"
59+
android:minWidth="64dp"
60+
android:minHeight="36dp"
6461
android:layout_marginStart="8dp" />
6562
</LinearLayout>
66-
</com.google.android.material.card.MaterialCardView>
63+
</LinearLayout>
6764
</com.google.android.gms.ads.nativead.NativeAdView>

0 commit comments

Comments
 (0)