Skip to content

Commit 3504fb7

Browse files
Create native ad layouts for start project lesson
1 parent ee6b06d commit 3504fb7

File tree

3 files changed

+136
-2
lines changed

3 files changed

+136
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
android:layout_width="match_parent"
7575
android:layout_height="wrap_content"
7676
android:layout_marginTop="24dp"
77-
app:layout_constraintTop_toBottomOf="@id/card_view_first_step" />
77+
app:layout_constraintTop_toBottomOf="@id/card_view_first_step"
78+
app:nativeAdLayout="@layout/ad_start_project_top" />
7879

7980
<com.google.android.material.textview.MaterialTextView
8081
android:id="@+id/text_view_second_step"
@@ -171,7 +172,8 @@
171172
android:layout_width="match_parent"
172173
android:layout_height="wrap_content"
173174
android:layout_margin="24dp"
174-
app:layout_constraintTop_toBottomOf="@id/lottie_animation" />
175+
app:layout_constraintTop_toBottomOf="@id/lottie_animation"
176+
app:nativeAdLayout="@layout/ad_start_project_bottom" />
175177
</androidx.constraintlayout.widget.ConstraintLayout>
176178
</me.zhanghai.android.fastscroll.FastScrollScrollView>
177179
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<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"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content">
6+
7+
<com.google.android.material.card.MaterialCardView
8+
android:id="@+id/ad_card"
9+
style="@style/Widget.Material3.CardView.Elevated"
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
app:shapeAppearanceOverlay="@style/ShapeTokens.Clover">
13+
14+
<LinearLayout
15+
android:layout_width="match_parent"
16+
android:layout_height="wrap_content"
17+
android:orientation="vertical"
18+
android:padding="16dp">
19+
20+
<include layout="@layout/ad_attribution" />
21+
22+
<LinearLayout
23+
android:layout_width="match_parent"
24+
android:layout_height="wrap_content"
25+
android:layout_marginTop="8dp"
26+
android:gravity="center_vertical"
27+
android:orientation="horizontal">
28+
29+
<androidx.appcompat.widget.AppCompatImageView
30+
android:id="@+id/ad_app_icon"
31+
android:layout_width="60dp"
32+
android:layout_height="60dp"
33+
android:layout_marginEnd="16dp" />
34+
35+
<LinearLayout
36+
android:layout_width="0dp"
37+
android:layout_height="wrap_content"
38+
android:layout_weight="1"
39+
android:orientation="vertical">
40+
41+
<TextView
42+
android:id="@+id/ad_headline"
43+
android:layout_width="match_parent"
44+
android:layout_height="wrap_content"
45+
android:ellipsize="end"
46+
android:maxLines="1"
47+
android:textAppearance="@style/TextAppearance.Material3.TitleSmall" />
48+
49+
<TextView
50+
android:id="@+id/ad_body"
51+
android:layout_width="match_parent"
52+
android:layout_height="wrap_content"
53+
android:layout_marginTop="4dp"
54+
android:ellipsize="end"
55+
android:maxLines="2"
56+
android:textAppearance="@style/TextAppearance.Material3.BodySmall" />
57+
58+
<me.zhanghai.android.materialratingbar.MaterialRatingBar
59+
android:id="@+id/ad_stars"
60+
style="@style/Widget.MaterialRatingBar.RatingBar.Small"
61+
android:layout_width="wrap_content"
62+
android:layout_height="wrap_content"
63+
android:layout_marginTop="4dp"
64+
android:isIndicator="true"
65+
android:numStars="5"
66+
android:stepSize="0.5" />
67+
</LinearLayout>
68+
69+
<com.google.android.material.button.MaterialButton
70+
android:id="@+id/ad_call_to_action"
71+
android:layout_width="wrap_content"
72+
android:layout_height="wrap_content"
73+
android:layout_marginStart="16dp" />
74+
</LinearLayout>
75+
</LinearLayout>
76+
</com.google.android.material.card.MaterialCardView>
77+
</com.google.android.gms.ads.nativead.NativeAdView>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<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"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content">
6+
7+
<com.google.android.material.card.MaterialCardView
8+
android:id="@+id/ad_card"
9+
style="@style/Widget.Material3.CardView.Elevated"
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
android:layout_marginHorizontal="24dp"
13+
app:shapeAppearanceOverlay="@style/ShapeTokens.Clover">
14+
15+
<LinearLayout
16+
android:layout_width="match_parent"
17+
android:layout_height="wrap_content"
18+
android:orientation="vertical"
19+
android:padding="16dp">
20+
21+
<include layout="@layout/ad_attribution" />
22+
23+
<com.google.android.gms.ads.nativead.MediaView
24+
android:id="@+id/ad_media"
25+
android:layout_width="match_parent"
26+
android:layout_height="180dp"
27+
android:layout_marginTop="8dp"
28+
android:scaleType="centerCrop" />
29+
30+
<TextView
31+
android:id="@+id/ad_headline"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
android:layout_marginTop="8dp"
35+
android:ellipsize="end"
36+
android:maxLines="1"
37+
android:textAppearance="@style/TextAppearance.Material3.TitleMedium" />
38+
39+
<TextView
40+
android:id="@+id/ad_body"
41+
android:layout_width="match_parent"
42+
android:layout_height="wrap_content"
43+
android:layout_marginTop="4dp"
44+
android:ellipsize="end"
45+
android:maxLines="2"
46+
android:textAppearance="@style/TextAppearance.Material3.BodyMedium" />
47+
48+
<com.google.android.material.button.MaterialButton
49+
android:id="@+id/ad_call_to_action"
50+
android:layout_width="wrap_content"
51+
android:layout_height="wrap_content"
52+
android:layout_marginTop="8dp" />
53+
</LinearLayout>
54+
</com.google.android.material.card.MaterialCardView>
55+
</com.google.android.gms.ads.nativead.NativeAdView>

0 commit comments

Comments
 (0)