Skip to content

Commit f9ffb25

Browse files
Refine ad attribution styling for native ads
1 parent 6c7a095 commit f9ffb25

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ You are an experienced Android app developer.
2020
## Native ads
2121
- Native ad XML layouts should wrap their content in a `MaterialCardView` with the ID `ad_card` using `@style/Widget.Material3.CardView.Outlined` and appropriate rounded corner overlays.
2222
- Use the shared `@layout/ad_attribution` snippet for displaying the ad attribution text.
23+
- Place the attribution include as the first child of the ad card and override its padding, background, or text color attributes to fit each layout.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
33
<solid android:color="@android:color/transparent" />
4-
<stroke android:width="1dp" android:color="?attr/colorPrimary" />
4+
<stroke android:width="1dp" android:color="?attr/colorOutline" />
55
<corners android:radius="4dp" />
66
</shape>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
3+
<solid android:color="@android:color/transparent" />
4+
<stroke android:width="1dp" android:color="?attr/colorOutline" />
5+
<corners android:radius="8dp" />
6+
</shape>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
3+
<solid android:color="@android:color/transparent" />
4+
<stroke android:width="1dp" android:color="?attr/colorPrimary" />
5+
<corners android:radius="4dp" />
6+
</shape>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
android:paddingHorizontal="4dp"
88
android:paddingVertical="2dp"
99
android:text="@string/ad"
10-
android:textColor="?attr/colorPrimary"
10+
android:textColor="?attr/colorOutline"
1111
android:textAppearance="@style/TextAppearance.Material3.LabelSmall" />

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,26 @@
55
android:layout_height="wrap_content">
66

77
<com.google.android.material.card.MaterialCardView
8+
android:id="@+id/ad_card"
89
style="@style/Widget.Material3.CardView.Outlined"
910
android:layout_width="match_parent"
1011
android:layout_height="wrap_content"
1112
app:cardCornerRadius="24dp">
1213

14+
<include
15+
layout="@layout/ad_attribution"
16+
android:layout_margin="16dp"
17+
android:layout_gravity="top|start"
18+
android:background="@drawable/bg_ad_attribution_large"
19+
android:paddingHorizontal="8dp"
20+
android:paddingVertical="4dp" />
21+
1322
<LinearLayout
1423
android:layout_width="match_parent"
1524
android:layout_height="wrap_content"
1625
android:layout_margin="16dp"
1726
android:orientation="vertical">
1827

19-
<include layout="@layout/ad_attribution" />
20-
2128
<com.google.android.material.card.MaterialCardView
2229
style="@style/Widget.Material3.CardView.Filled"
2330
android:layout_width="match_parent"

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
android:orientation="vertical"
2121
android:padding="16dp">
2222

23-
<include layout="@layout/ad_attribution" />
23+
<include
24+
layout="@layout/ad_attribution"
25+
android:background="@drawable/bg_ad_attribution_small"
26+
android:paddingHorizontal="4dp"
27+
android:paddingVertical="2dp"
28+
android:textColor="?attr/colorPrimary" />
2429

2530
<LinearLayout
2631
android:layout_width="match_parent"

0 commit comments

Comments
 (0)